Use reshape to tabulate

· Data manipulation, GNU-R
Authors

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

melt(sl1,id.var=,measure.var=”foo”)->sl2

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.

cast(sl2,formula,fun)

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.

 

Technorati:

%d bloggers like this: