Re: [R] find position to last number in a vector

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Sat 27 May 2006 - 04:47:46 EST


Is this what you want?

> x

 [1] NA NA 10 NA 2 NA NA 1 NA NA
> y

 [1] 10 20 30 40 50 60 70 80 85 100
> y[max(which(!is.na(x)))]

[1] 80

Andy

From: Anders Bjørgesæter
>
> Hello
>
> Is there a function to extract the position (i.e. row number or more
> desirable the value from another column with the same rownumber ) of
> last number in a vector? This is done in a loop with 1000s of columns.
>
> e.g.
>
> vector/column.n: na,na,10,na,2,na,na,1,na,na
> fixed column:10,20,30,40,50,60,70,80,85,100
>
> result: 8 and/or 80
>
> Thanks...
>
> Best Regards
> Anders
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat May 27 04:51:29 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 27 May 2006 - 06:10:29 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.