Re: [R] deleting certain observations in a data frame

From: Chang Liu <changisme_at_hotmail.com>
Date: Mon, 25 Feb 2008 14:12:12 -0800

Thanks Peter:  

For others who are interested, the first one one with [-indices,] doesn't really do, because the first level of indices are the component names. eg, if I have a data frame with variables, name, DOB, gender, then by using the first choice, I'm merely deleting lists of variables, but thanks Peter for the second trick. That one works for deleting the actually data entries.  

Karen> Subject: RE: [R] deleting certain observations in a data frame> Date: Fri, 15 Feb 2008 10:05:39 +1300> From: PAlspach_at_hortresearch.co.nz> To: changisme_at_hotmail.com; r-help_at_r-project.org> > 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@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.


        [[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. Received on Mon 25 Feb 2008 - 22:15:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 25 Feb 2008 - 23:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive