s-news
[Top] [All Lists]

Re: getting rid of certain dataframe rows

To: "Leeds, Mark" <mleeds@mlp.com>
Subject: Re: getting rid of certain dataframe rows
From: Sundar Dorai-Raj <sundar.dorai-raj@PDF.COM>
Date: Wed, 17 Dec 2003 13:03:25 -0600
Cc: s-news@wubios.wustl.edu
In-reply-to: <54668D97C0199943A454516A5FF6481E093DEE@EXCHUS001.AD.MLP.COM>
Organization: PDF Solutions, Inc.
References: <54668D97C0199943A454516A5FF6481E093DEE@EXCHUS001.AD.MLP.COM>
Reply-to: sundar.dorai-raj@PDF.COM
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

Leeds, Mark wrote:

i don't  think this is so hard but i don't know how to do it.
i have a dataframe and one of the columns is data$date.
( there are many other columns also ).
the format for the data$date is dd-mmm-yy and it's a string. i have a list of dates ( say 15 dates ) for which i want to get rid of
the whole row that has that date as the value for data$date.
for example, i know that i want to get rid of the whole
row for which data$date is "02-Jan-02".
i can do the statement multiple times so there
is no need to be clever about doing it all in one statement.
if the list of dates that i have is 15,
i can type the same command 15 times, that's not a problem.
thanks a lot and sorry to bother everyone.

Use %in% or is.element and matrix indexing:

data[!data$date %in% c("02-Jan-02", "03-Jan-02"), ]

or

data[!is.element(data$date, c("02-Jan-02", "03-Jan-02")), ]

Regards,
Sundar



<Prev in Thread] Current Thread [Next in Thread>