Skip to content

tabulate: switching columns and rows

2 messages · Ricardo Rodríguez, Hadley Wickham

#
Thanks, Hadley,
 
My fault: I've not provided the line concerning replicate variable. It is included in ?xtabs:

warpbreaks$replicate <- rep(1:9, len = 54)

It will be great to have an example with these given data. Anyway, I will have a look to reshape at the given site. Thanks a lot!

Cheers,

Ricardo




--
Ricardo Rodr?guez
Your XEN ICT Team
#
install.packages("reshape")
library(reshape)

wm <- melt(warpbreaks, m="breaks")
cast(wm, wool ~ tension + replicate)

# Or as a 3d array
cast(wm, wool ~ tension ~ replicate)

# Or aggregate over replicates:
cast(wm, wool ~ tension, mean)
cast(wm, wool ~ tension, length)

Regards,

Hadley