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
|