[R] Skip last NA's?

2006-03-02 Thread Robert Lundqvist
I wonder if anyone could help me find an expression for skipping the last missing values in a vector? The kind of material I have is something like x-c(23,12,NA,23,24,21,NA,NA,NA) I would like to skip the last NA's, but not the ones in between other vallues. Any hints? (Why not do this by simply

Re: [R] Skip last NA's?

2006-03-02 Thread Patrick Burns
A fairly standard trick for such situations is to use rle(is.na(x)) In your case you want to see if the last value is TRUE. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Robert Lundqvist wrote: I

Re: [R] Skip last NA's?

2006-03-02 Thread Petr Pikal
: Robert Lundqvist [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Subject:[R] Skip last NA's? Send reply to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] I wonder if anyone could help me find an expression

Re: [R] Skip last NA's?

2006-03-02 Thread Gabor Grothendieck
Do you mean you wish to create a vector without the trailing NAs but with the others? If so, try: library(zoo) head(x, length(na.locf(x, rev = TRUE))) or library(zoo) head(x, length(na.locf(rev(x On 3/2/06, Robert Lundqvist [EMAIL PROTECTED] wrote: I wonder if anyone could help me find

Re: [R] Skip last NA's?

2006-03-02 Thread J. Hosking
Robert Lundqvist wrote: I wonder if anyone could help me find an expression for skipping the last missing values in a vector? The kind of material I have is something like x-c(23,12,NA,23,24,21,NA,NA,NA) I would like to skip the last NA's, but not the ones in between other vallues. Any