My dataframe looks like this:
V1 V2
colors1 black;yellow;green
colors2 blue;pink;purple
I am trying to transform this df into a frequency matrix using dcast: dcast(df, V2~V1) but I need to split the second column strings into separate values like this:
V1 V2
colors1 black
colors1 yellow
colors1 green
colors2 blue
colors2 pink
colors2 purple
Is there an easy way to do this?