Use reshape to tabulate

· Data manipulation, GNU-R

Package reshape is meant for aggregating, reshaping and tabulating data.Tabulation is done in two steps: melt and cast. Read help for these functions.


This will create a dataframe sl2 which will have all the variablesin sl1 and “foo” being reorganised for casting later. See head(sl2) to see the form it takes.

The following command takes the molten dataframe and produces a table.


where fun is the aggregating function you want to use. The formula takes the form var1~var2~var3. See help for cast for more details on specification of the formula.



%d bloggers like this: