Home > front end >  how to filter in R based off specific key words and use in ggplot
how to filter in R based off specific key words and use in ggplot

Time:05-02

I have a csv file that contains movie names, budgets, profit, and genre. There are 15 genres, but I want to plot the budgets of only 5 of the genres which are action, adventure, comedy, drama and animation. how do I filter for movies that fall in these genres?

CodePudding user response:

You could filter 5 genres using filter from dplyr,

target_genres <- c( 'action', 'adventure', 'comedy', 'drama', 'animation')
filtered <- df %>% filter(genres %in% target_genres)
  • Related