> This does it more or less your way: > > ds <- split(df, df$Name) > ds <- lapply(ds, function(x){x$Index <- seq_along(x[,1]); x}) > df2 <- unsplit(ds, df$Name) > tapply(df2$X1, df2[,c("Name", "Index")], function(x) x) > > athough there may exist much easier ways ...
Here's one way with the plyr and reshape package: library(plyr) df.index <- ddply(df, .(Name), transform, Index = seq_along(X1)) library(reshape) cast(df.index, Name ~ Index, value = "X1") 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.