1:35 PM
> To: gallon li
> Cc: R-help@r-project.org
> Subject: Re: [R] select element from each row of the matrix
>
>
> On Jul 20, 2011, at 4:23 PM, gallon li wrote:
>
> > I have a 5 column matrix like
> >
> > 12 10 8 6 3
> > 10 9 8 7 5
> > 14 NA
21 July 2011 8:23 a.m.
> To: R-help@r-project.org
> Subject: [R] select element from each row of the matrix
>
> I have a 5 column matrix like
>
> 12 10 8 6 3
> 10 9 8 7 5
> 14 NA 4 NA NA NA
> 15 NA 10 NA 5
> ...
>
> I want to select the position of the first ent
On Jul 20, 2011, at 4:23 PM, gallon li wrote:
I have a 5 column matrix like
12 10 8 6 3
10 9 8 7 5
14 NA 4 NA NA NA
15 NA 10 NA 5
...
Probably something along the lines of
aapply(mtx, 1, function(x) { c( x[ which(x <= 5)[1] ], # first row are
the values
whi
I have a 5 column matrix like
12 10 8 6 3
10 9 8 7 5
14 NA 4 NA NA NA
15 NA 10 NA 5
...
I want to select the position of the first entry for each row <=5
for example, for the first row, I want to select the last element and return
its position as 5;
for th e third row, I want to select the third
4 matches
Mail list logo