This article describes how to go from multiple tables with more than one statistic...
...to a single combined table:
Requirements
A Displayr document with a set of tables containing 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.
Method
1. Select the first table and copy the name from Properties > GENERAL > Name.
2. Repeat step 1 for the second table. These names will be used in the code below.
3. Select Calculation > Custom Code.
4. In the object inspector, go to Properties > R CODE.
5. In the code field, add a line to load the abind R package:
library(abind)
6. Add a line that calls the (abind)
function, like the below example. In this, new.table 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 = abind(table.preferences, table.satisfaction, 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)[[3]] = c("Score","Sample Size")
8. Add a line that references the new.table set in step 6:
new.table
The complete code to generate the example above is:
#call library of functions needed
library(abind)
#combine tables
new.table = abind(table.preferences, table.satisfaction, along = 1)
#name statistics
dimnames(new.table)[[3]] = c("Score","Sample Size")
#call final table
new.table
Comments
0 comments
Article is closed for comments.