Hi,
I am a new R user (used SPSS for many years) and I need help. 
I have a data frame mydata with 8 variables m2008:m2001
I wanted to add a new variable mydata$firstvalid that tells me what is the
first non missing variable for each case (without using for-next).
I tried many variations of this: 
lst  = paste("m",2008:2001,sep="")
mydata$firstvalid = match(FALSE, is.na(mydata[lst]),0)
Instead of a different value for each case, I get the same value for all
cases - the first non missing value in the whole data frame.
Many thanks,
Moti Assouline 
 
 


Checked by AVG. 

20:52

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to