Re: [R] Dropping rows conditionally

2009-03-05 Thread Jason Rupert
: From: Lazarus Mramba lmra...@kilifi.kemri-wellcome.org Subject: [R] Dropping rows conditionally To: r-help@r-project.org Date: Thursday, March 5, 2009, 12:18 AM Dear R-help team, I am getting addicted to using R but keep on getting many challenges on the way especially on data management (data

Re: [R] Dropping rows conditionally

2009-03-05 Thread David Winsemius
There are functions for this purpose: ?na.omit # dispays help page for na.fail, na.omit, na.exclude, na.pass -- David Winsemius On Mar 5, 2009, at 1:18 AM, Lazarus Mramba wrote: Dear R-help team, I am getting addicted to using R but keep on getting many challenges on the way

[R] Dropping rows conditionally

2009-03-04 Thread Lazarus Mramba
Dear R-help team, I am getting addicted to using R but keep on getting many challenges on the way especially on data management (data cleaning). I have been wanting to drop all the rows if there values are `NA' or have specific values like 1 or 2 or 3. mdat - matrix(1:21, nrow = 7, ncol=3,

Re: [R] Dropping rows conditionally

2009-03-04 Thread Adrian Dusa
Hi Lazarus, It would be more simple with mdat as a matrix (before coercing to a data.frame). It might be a simpler way to compare a matrix with a vector but I don't find it for the moment; in any case, this works: mdatT - matrix(mdat %in% c(1, 11, 20), ncol=3) mdat[!apply(mdatT, 1, any), ]