How do we know what value corresponds to what new
variable?
library(reshape)
mm <- melt(d, id="group")
cast(mm, group~value)
will give you something but not quite what you want.
--- Shubha Vishwanath Karanth
<[EMAIL PROTECTED]> wrote:
> Hi R,
>
>
>
> Can I transpose a data frame by a part
Try also:
reshape(cbind(d, time=unlist(sapply(table(d$group), seq))),
idvar="group", direction="wide")
On 14/02/2008, Shubha Vishwanath Karanth <[EMAIL PROTECTED]> wrote:
> Hi R,
>
>
>
> Can I transpose a data frame by a particular group variable?
>
>
>
> For example:
>
> d=data.frame(group=c(
try this:
d <- data.frame(group = c(1,1,2,2,2), val = c(6,4,6,3,5))
d$time <- unlist(tapply(d$group, d$group,
function (x) seq(1, len = length(x
reshape(d, idvar = "group", direction = "wide")
I hope it helps.
Best,
Dimitris
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
3 matches
Mail list logo