On Mon, Apr 6, 2009 at 10:40 AM, baptiste auguie <ba...@exeter.ac.uk> wrote: > Here's one attempt with plyr, hopefully Hadley will give you a better > solution ( I could not get cast() to do it either) > > test <- > data.frame(a=c("A","A","A","A","B","B","B"),b=c(1,1,2,2,1,1,1),c=sample(1:7)) > ddply(test,.(a,b),.fun=function(.) paste(.)[3])
This is a problem that currently isn't very easy to solve in plyr (but I'm working on it). About the best you can do is: ddply(test, ~ a + b, colwise(paste, .(c)), collapse =",") (this is basically equivalent to your suggestion) Hadley -- http://had.co.nz/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.