1

I have a dataset with 13 species under one column "species name" and need to remove 3 of them from the dataset before analysis. So using the iris data as an example, to remove 1 of them I know it would be something like

iris <- subset(iris, Species!="versicolor")

or if I wanted to keep one of them,

iris <- iris[iris$Species == "setosa", ]

But I can't figure out the code if I wanted to remove/keep more than 1 species. Any help would be appreciated!

1
  • 5
    Use subset(iris, !Species %in% c("setosa", "versicolor")) Commented May 10, 2021 at 23:15

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.