[R] Subsets without NA

Gary Collins gco at eortc.be
Tue Jan 8 13:40:26 CET 2002


try
> x.old
   V1 V2 V3 V4
1 NA  2  3  4
2  5  6  7  8
3  9 NA 11 12
4  1  2  3  4

> x.new_x.old[-c(unique(which(apply(is.na(x.old),  FUN=any,
MARGIN=1)==TRUE))),]
> x.new
  V1 V2 V3 V4
2  5  6  7  8
4  1  2  3  4

removes a row with at least 1 missing value
if you want to take out rows which have all missing values, change the FUN
to all

Gary
__________________________________________________
Gary S. Collins, PhD,
Statistics Research Fellow,
Quality of Life Unit,
European Organisation for Research and Treatment of Cancer,
EORTC Data Center,
Avenue E. Mounier 83, bte. 11,
B-1200 Brussels, Belgium.

Tel: +32 2 774 1 606
Fax: +32 2 779 4 568
http://www.eortc.be/home/qol/
__________________________________________________



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list