I have a nasty data table that has a couple of different kinds of messiness, and I can't figure out how to combine some of the other answers that use the tidyr and splitstackshape packages.
subject <- c("A", "B", "C")
review <- c("Bill: [1.0]", "Bill: [2.0], Cathy: [3.0]", "Fred: [4.0], Cathy: [2.0]")
data.table(cbind(subject, review))
which gives:
subject review
1: A Bill: [1.0]
2: B Bill: [2.0], Cathy: [3.0]
3: C Fred: [4.0], Cathy: [2.0]
This exhibits tidyr messiness with multiple variables stored in one column, along with some ugly formatting.
What I want is a table like:
subject Bill Fred Cathy
A 1.0 0.0 0.0
B 2.0 0.0 3.0
C 0.0 4.0 2.0