[R] Finding nrows with specefic values&converting a matrix into a table
abo dalash
abo_dlsh at hotmail.com
Sat Apr 29 17:13:44 CEST 2017
Hi All
I'm trying to identify number of rows containing 2 specific values.
I tried : which(mydata == 566,235), but this returns logical values for all rows and any T in a certain row indicates the existence of one of these values but what I need to know is only number of rows in my data set with these 2 particular values considering these two values
as one pair per column. For example :
1 123 566 235
2 443 54 566
3 566 44 235
here number of rows with the values 566&235 is 2 which are
rows 1 & 3. Row 2 has only 566 so it should not be included in
our calculation.
I also have a large matrix and wanted to convert it into a table so I can
easily identify the combination with higher frequencies.
The matrix looks like this:
x y z
x 0 5 67
y na 0 23
z na na 0
and I would like to convert this into a table arranged with
higher values first like this :
x z 67
y z 23
x y 5
x x 0
y y 0
z z 0
y x na
z x na
z y na
Is there simple function to perform this conversion with some explanation about the Syntax
Regards
[[alternative HTML version deleted]]
More information about the R-help
mailing list