How do you split the multiple values of a variable in R programming.
Like, in the image the genre has multiple values in it's cells. how do you separate them and get count of the values in a table.
How do you split the multiple values of a variable in R programming.
Like, in the image the genre has multiple values in it's cells. how do you separate them and get count of the values in a table.
We can use separate_rows
library(dplyr)
library(tidyr)
df1 %>%
separate_rows(Genre) %>%
count(Genre)
Or using base R
table(unlist(strsplit(df$Genre, ",\\s*")))