Skip to content
Prev 106796 / 398526 Next

tabulate: switching columns and rows

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