This is probably a very trivial question… I have a table similar to this:
tbl1 <- data.frame(rbind(
c("N1","G1","a"),
c("N1","G1","b"),
c("N1","G2","d"),
c("N2","G1","e"),
c("N2","G1","f"),
c("N2","G2","g")
))
Which I want to convert it to this:
X1 | G1 | G2
N1 | c("a","b") | "d"
N2 | c("e","f") | "g"
I’m thinking this is the direction to go, but what should the “?” be set to?
tbl2 <- data.frame(cast(tbl1,X1~X2, value="X3", ? ))
Thanks for all contributions to [r] at Stack Overflow!
/Chris
This actually does what you are asking for, although the printed version of the results looks a little odd at first sight. (The difficulty in printing it nicely, of course, is that this is a data.frame in which some “cells” are vectors with more than one element).
Especially if you need this for the information it contains (rather than for the printed object it produces), it could still serve your purposes just fine: