Skip to content
Prev 3164 / 7420 Next

Re-arrange data frame

Manuel,

You haven't specified the general problem, but for this particular
situation this is how you can do it:

x <- data.frame(array(1:12, c(3,4), list(paste("item", 1:3),
paste("col", 1:4))))
x <- data.frame(Item=rownames(x), x)
y <- data.frame(Item=x$Item[rep(1:3, each=2)],
matrix(as.matrix(x[,-1]), 6, 2, byrow=TRUE))

Cheers,

Peter

--
P?ter S?lymos, Dept Biol Sci, Univ Alberta, T6G 2E9, Canada AB
solymos at ualberta.ca, Ph 780.492.8534, http://psolymos.github.com
Alberta Biodiversity Monitoring Institute, http://www.abmi.ca
Boreal Avian Modelling Project, http://www.borealbirds.ca


2012/6/29 Manuel Sp?nola <mspinola10 at gmail.com>: