Define a new column for genre of the movie

There are several ways to do that using tidyverse tools. If you can provide a reprex, it will be easier to show you how.

What your new genre column will contain ? A concatenated string with all genre ? A vector of genre ? A list ?

I would suggest two approaches:

  • Replace in each column the TRUE values by the corresponding genre, then create a column to concatenate the strings or create the vector / list
  • Use a reshaping and filtering (something with gather, separate, filter, mutate) to add a column with row number, pass the column name in one column (several rows for each previous row number), keep only rows where values is true, reshape in one row per original row number creating a column genre.
2 Likes