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,
Checked by AVG.
R-help_at_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. Received on Thu 20 Mar 2008 - 05:02:29 GMT
Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Archive generated by hypermail 2.2.0, at Thu 20 Mar 2008 - 09:30:23 GMT.
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.
list of date sections of archive