Here I have a dataframe df1
that I would like to turn into a dataframe df2
. Does anybody have any suggestions/ideas?
df1 <- data.frame (ID = c("UniqueValue1", "UniqueValue2", "UniqueValue3",
"UniqueValue4", "UniqueValue5", "UniqueValue6"),
stringtext = c("Factor1:1.0, Factor2:2.0, Factor3:3.0"))
into...
df2 <- data.frame (ID = c("UniqueValue1", "UniqueValue2", "UniqueValue3",
"UniqueValue4", "UniqueValue5", "UniqueValue6"),
Factor1 = c("1.0", "1.0", "1.0", "1.0", "1.0", "1.0"),
Factor2 = c("2.0", "2.0", "2.0", "2.0", "2.0", "2.0"),
Factor3 = c("3.0", "3.0", "3.0", "3.0", "3.0", "3.0"))
Is there a way where you don't have to manually specify 'Factor1', 'Factor2', and 'Factor3'? Like if whatever is behind the colon, turn that into a column, and what ever is AFTER the colon, turn that into its specific value. If we can get that, that would be awesome. Any help or feedback regarding this would be highly appreciated! Thanks!