[R] Matrix-list table conversion+nrwos with specefic values.
Bert Gunter
bgunter.4567 at gmail.com
Sat Apr 29 18:53:08 CEST 2017
I am not a private (or free!) consultant. Post to the r-help if your
question concerns R.
-- Bert
Bert Gunter
On Sat, Apr 29, 2017 at 8:51 AM, abo dalash <abo_dlsh at hotmail.com> wrote:
> Hi dear Bert
>
>
> 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 row. 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 a simple function to perform this conversion with some explanation
> about the Syntax if you don't mind?
>
>
> Regards
More information about the R-help
mailing list