[R] Dropping rows conditionally
dwinsemius at comcast.net
Thu Mar 5 13:46:56 CET 2009
There are functions for this purpose:
?na.omit # dispays help page for na.fail, na.omit, na.exclude,
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 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, byrow=TRUE,
> dimnames = list(c("row1",
> c("C.1", "C.2", "C.3")))
> C.1 C.2 C.3
> row1 1 2 3
> row2 4 5 6
> row3 7 8 9
> row4 10 11 12
> row5 13 14 15
> row6 16 17 18
> row7 19 20 21
> I want to say drop row if value=1 or value =11 or value =20
> How do I do that?
> Kind regards,
> Lazarus Mramba
> Junior Statistician
> P.O Box 986, 80108,
> Kilifi, Kenya
> Mobile No. +254721292370
> Tel: +254 41 522063
> Tel: +254 41 522390
> (office extension : 419)
> This e-mail (including any attachment to it) contains information
> which is confidential. It is intended only for the use of the named
> recipient. If you have received this e-mail in error, please let us
> by replying to the sender, and immediately delete it from your system.
> Please note, that in these circumstances, the use, disclosure,
> distribution or copying of this information is strictly prohibited. We
> apologize for any inconvenience that may have been caused to you.
> KEMRI-Wellcome Trust Programmecannot accept any responsibility for
> the accuracy
> or completeness of this message as it has been transmitted over a
> network. KEMRI-Wellcome Trust Programme reserves the right to
> monitor all incoming and
> outgoing email traffic. Although the Programme has taken reasonable
> precautions to ensure no viruses are present in emails, it cannot
> accept responsibility for any loss or damage arising from the use of
> email or attachments. Any views expressed in this message are those of
> the individual sender, except where the sender specifically states
> to be the views of KEMRI- Wellcome Trust Programme".
> R-help at r-project.org mailing list
> 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