[R] deleting certain observations in a data frame
Peter Alspach
PAlspach at hortresearch.co.nz
Thu Feb 14 22:05:39 CET 2008
Karen
For indices, use the minus sign: yourData[-indicesToBeDeleted,]
For rownames, negate %in%:
yourData[!rownames(yourData)%in%namesToBeDeleted,]
HTH
Peter Alspach
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Chang Liu
> Sent: Friday, 15 February 2008 9:50 a.m.
> To: r-help at r-project.org
> Subject: [R] deleting certain observations in a data frame
>
>
> Hi, I'm wondering what the fastest way is to delete certain
> data points (observations) in a data frame.
> I have a vector of the indices/row.names I would like to
> delete. I have tried replacing list by list, but it always
> complains about different lengths, "replacing list of length
> a with length b" and so on.
>
> Another way to think of it is that it's a generazation of
> na.rm I guess.
>
> Thanks,
> Karen
> _________________________________________________________________
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
The contents of this e-mail are privileged and/or confidential to the named
recipient and are not to be used by any other person and/or organisation.
If you have received this e-mail in error, please notify the sender and delete
all material pertaining to this e-mail.
More information about the R-help
mailing list