[R] subset data frame by variable with missing value

Milan Bouchet-Valat nalimilan at club.fr
Fri Nov 30 17:02:35 CET 2012


Le vendredi 30 novembre 2012 à 07:27 -0800, ramoss a écrit :
> Hello,
> 
> I have a variable in a data frame that contains NA values. I just want to
> subset so that I get the obs where that variable is missing.
> In SAS I would do:
> 
> data missing;
>   set test;
>   if myvalue=' ';
> run;
> 
> How can I perform this simple task in R?
missing <- test[is.na(test$myvalue),]
or
missing <- subset(test, is.na(myvalue))


Regards

> Thanks in advance for your help. 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/subset-data-frame-by-variable-with-missing-value-tp4651439.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.




More information about the R-help mailing list