I have a data frame with something like the following structure:
Trial Index Condition1 Condition2 Measures
1 A Y ...
2 A Y ...
3 B Y ...
4 B Y ...
5 A Z ...
6 A Z ...
7 B Z ...
8 B Z ...
I would like to compute a number of summary measures on each combination of Condition1 and Condition2, and for the margins. I can use multiple calls to ddply to do this, but I was wondering if there is some simple way to get a single data structure out of it, something like:
Condition1 Condition2 Mean Median ....
A Y ... ... ....
A Z ... ... ....
A - ... ... ....
B Y ... ... ....
B Z ... ... ....
B - ... ... ....
- Y ... ... ....
- Z ... ... ....
@DWin is right,
tablespackage might be the right clue here. Without taking care of formating here’s an example:It takes a while to get into the syntax though; on the plus side it provides functionality to export the tables to LaTeX. If you don’t want/need all the labeling in that
tabularobject you can extract the values viaas.matrix(t1, format = as.numeric).NOTE:
c1andc2on the left hand side of the formula have to befactorfor this to work