Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Use melt() from the reshape2 package. In the anthoming data set, for each angle, there are
two measurements: one column contains measurements in the experimental
condition and the other contains measurements in the control
condition:
library(gcookbook)# For the data setanthomingangle expt ctrl-2010-107302310032001
We can reshape the data so that all the measurements are in one
column. This will put the values from expt and ctrl into one column, and put the names into a
different column:
library(reshape2)melt(anthoming,id.vars="angle",variable.name="condition",value.name="count")angle condition count-20expt1-10expt70expt210expt020expt0-20ctrl0-10ctrl30ctrl310ctrl320ctrl1