I'm sorry if I couldn't make the question clear enough. I'm having difficulty forming the search keyword/phrase, so here I am.
So, I currently have a data frame something like this:
song.title <- c("A", "B", "C", "D")
genre <- c("rock", "pop, rock", "jazz, pop, funk", "funk, rock")
df <- data.frame(song.title, genre)
view(df)
Then, I need to convert the data frame to something like this:
song.title <- c("A", "B", "C", "D")
is.pop <- c("no", "yes", "yes", "no")
is.rock <- c("yes", "yes", "no", "yes")
is.jazz <- c("no", "no", "yes", "no")
is.funk <- c("no", "no", "yes", "yes")
df_needed <- data.frame(song.title, is.pop, is.rock, is.jazz, is.funk)
view(df_needed)
The actual data I'm working on has 10.000+ rows, so it's hard to determine how many factors (genres/tags) that should be "converted" to columns. What are my options to transform such kind of data in R? Thanks.