[R] How to re-arrange data in table?

hadley wickham h.wickham at gmail.com
Thu Feb 15 20:55:40 CET 2007


> I like to re-arrange a table (sTable) based on the value of one the rows
> (Analyte) as shown below. Blocks of data with different values for Analyte
> need to be stacked below each other. Any easy way to do this or any advice
> where to look?

How about:

library(reshape)
dfm <- melt(df, m="AUC")

cast(dfm, Analyte + result_variable ~ Dose, myStats)

# A few other variations
cast(dfm, Analyte ~ Dose ~ result_variable, myStats)
cast(dfm, Analyte + Dose ~ result_variable, myStats)

# See http://had.co.nz/reshape for more documentation

Hadley



More information about the R-help mailing list