This article describes how to go from multiple tables with more than one statistic...
...to a single combined table:
A set of tables with either:
- The same row dimensions and the same number of comparable statistics when appending columns to a table.
- The same column dimensions and the same number of comparable statistics when appending rows to a table.
1. Right-click the first table and copy the name from Reference Name.
2. Repeat step 1 for the second table. These names will be used in the code below.
3. Right-click in the Report tree and select Add R Output.
4. In the object inspector, go to Properties > R CODE.
5. In the code field, add a line to load the abind R package:
6. Add a line that calls the
(abind) function, like the below example. In this, new_table_name is an arbitrary name for the combined table, table1_name is the name of the first table name copied in step 1, above, and table2_name is the name of the second table from step 2. To combine tables over rows, set
along = 1. For columns use,
along = 2 and to combine matching tables with different statistics use,
along = 3.
new_table_name = abind(table1_name, table2_name, along = 1)
7. Add a line that defines the name of each statistic (if different between the input tables) using the format below, where Label1 is the combined label to use for the first statistic in both tables, and Label2 is for the second statistic.
dimnames(new_table_name)[] = c("label1","label2")
8. Add a line that references the new_table_name set in step 6:
The complete code to generate the example above is:
#call library of functions needed
new.table = abind(table.preferences, table.satisfaction, along = 1)
dimnames(new.table)[] = c("Score","Sample Size")
#call final table