Question
#R Programming I have read CSV file into a dataframe(df). I need to extract a column genre which has two or three items in a
#R Programming
I have read CSV file into a dataframe(df). I need to extract a column genre which has two or three items in a row with a comma in between. (e.g: Drama, History, Romance) or (Drama, History) or (Drama, Drama, Horror)
I have used code :
df <- na.omit(df). #for removing nan values
Genre <- unique(unlist(strsplit(as.character(df$Genre), ","))). # to separate genre between comma(,)
Now, I need to get rid of repeated genres from Genre.(e.g: change (Drama, Drama, Horror) to
Drama
Horror
,
I have tried using duplicated(Genre) but since the type of "Genre" is a character it will give you False as an output. I need to print a list of unique genres in the dataset.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started