'Subset dataset with several levels of a categorical variable

I want to subset a dataset with several levels of a categorical variable in Rstudio.

With the function "subset" I am able to do it with just one level

new_df<-subset(df, df$cat.var=="level.1")

How do I subset with more than one levels?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source