Remove Rows From Data Frame where a Row matches a String
Just use the ==
with the negation symbol (!
). If dtfm is the name of your data.frame:
dtfm[!dtfm$C == "Foo", ]
Or, to move the negation in the comparison:
dtfm[dtfm$C != "Foo", ]
Or, even shorter using subset()
:
subset(dtfm, C!="Foo")
You can use the dplyr
package to easily remove those particular rows.
library(dplyr)
df <- filter(df, C != "Foo")