I have the following dataframe:
df <- data.frame(Sl.No = c(1:6), Variable = c(\'a\', \'a,b\', \'a,b,c\', \'b\', \'c\', \'b,c\'))
We can split the Variable column at "," and get all the values and select only the unique ones.
Variable
unique
unique(unlist(strsplit(df$Variable, ","))) #[1] "a" "b" "c"
If the Variable column is factor convert it into character before using strsplit.
strsplit