Download

The Pivottable Toolbox has functions for the flexible tabulation of data frames. Many tedious and repetitive aspects of data analysis become a one-line command. Read under the utililty-toolbox about data structures first.

Let's assume we have a dataset from a virtual experiment, in which N=20 subjects, either patients or non-patients, produced 5, 7, 10, or 20cm movements under visual-feedback and no-feedback conditions. The dependent variables are movement time, accuracy, and the actual trajectories.

The data structure looks like:
D =
       SN: [160x1 double]
    Group: {160x1 cell}
     ampl: [160x1 double]
 feedback: [160x1 double]
       MT: [160x1 double]
 accuracy: [160x1 double]

Examples of usage

Basic usage
pivottable(D.group,D.ampl,...
D.MT,'mean');
     | 5.00  7.00   10.00  20.00
-----|------ ------ ------ ------
1.00 |213.82 251.24 298.95 382.68
2.00 |262.81 323.07 370.30 549.97

The Basic usage is pivottable(row, columns, field, fieldcommand). The fieldcommand determines the statistic that is calculated in each cell (mean in this case). If no return argument is given, the table is printed in the screen. If a return argument is given, the body of the table is returned as a matrix. 

Nested variables
pivottable...
([D.group D.feedback],...
D.ampl,D.MT,'median');
          | 5.00  7.00   10.00  20.00
---  ---- |------ ------ ------ ------
1.00 0.00 |192.17 249.84 274.13 346.99
1.00 1.00 |235.47 252.64 323.77 418.38
2.00 0.00 |219.94 293.32 296.21 454.02
2.00 1.00 |305.69 352.81 444.39 645.93

Now the column has two nested variables, the first one is group, the second one feedback. This time the median of the data is returned.

Subsetting data
pivottable(D.group,D.ampl,...
D.MT,'length',...
'subset',D.accuracy<1);
     | 5.00  7.00 10.00  20.00
---- |----- ----- ----- -----
1.00 | 9.00 13.00  5.00  7.00
2.00 | 1.00  2.00  1.00  5.00
 

We can restrict the tabulation to data with a an accuracy better than 1 cm. In this case we give the count (length of variable) in each field.

More complex statistics
pivottable(D.group,D.ampl,...
D.accuracy,...
'sqrt(mean(x.^2))');
     | 5.00  7.00 10.00 20.00
---- |----- ---- ----- -----
1.00 | 1.80 1.21 1.55 1.53
2.00 | 3.32 3.45 3.10 2.64

Field commands can also be more complex strings. Each time a x is placed, the data in this cell as a column oriented vector is inserted. This command prints the root-mean-square of the variable accuracy.

List of functions

1. Pivot Table Functions
pivottable All-purpose pivot table for tabulation
tapply Condenses a Data structure into another
2. Utility functions
pidata Sorts the data into an cell-array
print_pivot Formated output on screen
fac2int Conversion of string-valued variable (factor) into intergers
int2fac Backwards conversion
3. Example function for field commands
corr Correlation
stderr Standard error (sd/sqrt(N))

Joern's Home Page
Jörn Diedrichsen's
Homepage
Matlab Toolboxes
Matlab
Toolboxes