Data Extraction
Hi Sarah, I am glad you have precisely caught where I made the mistake. Thank you so much. regards, Pradip Muhuri
From: Sarah Goslee [sarah.goslee at gmail.com]
Sent: Thursday, November 22, 2012 9:21 AM
To: Muhuri, Pradip (SAMHSA/CBHSQ)
Cc: r-help at r-project.org
Subject: Re: [R] Data Extraction
Sent: Thursday, November 22, 2012 9:21 AM
To: Muhuri, Pradip (SAMHSA/CBHSQ)
Cc: r-help at r-project.org
Subject: Re: [R] Data Extraction
Hi, is.na<http://is.na/>( X1 | X2 | X3 | X4 | X5) isn't a valid construct. You'd need !(is.na<http://is.na>(X1) | is.na<http://is.na>(X2) etc ) Or more elegantly df1[apply(df1, 1, function(x)all(!is.na<http://is.na>(x))), ] Sarah On Thursday, November 22, 2012, Muhuri, Pradip (SAMHSA/CBHSQ) wrote: Hello, I would appreciate if someone could help me resolve the following: 1. df1[!is.na<http://is.na>( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work 2. Is these message harmful? The following object(s) are masked from 'df1 (position 3)': X1, X2, X3, X4, X5 Thanks, Pradip Muhuri #Reproducible Example set.seed(5) df1<-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5)) attach (df1) #delete rows if any of them NA for X1 df1[!is.na<http://is.na>( X1),][,1:5] # This works #delete rows if any of them NA for X1, X2, X3, X4 or X5 df1[!is.na<http://is.na>( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work ______________________________________________ R-help at r-project.org<javascript:;> 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. -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org