This article describes how to combine two or more tables into a single merged table by combining either common row labels or common column labels. Before using the Combine Tables automation, you should consider whether the variables used in the tables should be joined together into a Variable Set instead, see How to Combine Variables into a Variable Set.
Otherwise, you can combine tables by rows where the join direction is side-by-side or combine by column where the join direction is up and down (tables are stacked on top of each other).
- Method 1 - Using the combine button
- Method 2 - Using the Anything menu
- Method 3 - Using the Table menu
Requirements
- A document containing two or more tables that you want to combine. Note that the combined table will only show the first Statistics > Cells of the table and any significance testing and Statistics added via the Below and Right dropdown will not carry through.
- Familiarity with the Structure and Value Attributes of Variable Sets as sometimes you can combine similar variables into a Multi or Grid variable set to show their data in the same table.
Method 1 - Using the combine button
1. Select each of the tables in your document that you want to merge by holding down your Ctrl key and selecting each table. In this example, we have 2 brand preference tables, each with the same row labels (brand), but with different column labels - the first table is cross-tabbed by age and the second by gender.
2. Right-click and select Combine. Displayr will automatically determine that the row labels are the same in each table and combine the tables with a side-by-side join direction.
Method 2 - Using the Anything menu
- Select the tables you want to combine on the page.
- Go to Anything
> Table > Combine Tables in the toolbar.
Method 3 - Using the Table menu
- Select the tables you want to combine on the page.
- Go to Table
> Combine Tables in the toolbar.
When using this function, it is important to be aware of the following:
- The joined table is generated using an R function.
- Significance testing from the original tables will not be displayed in the combined table.
- You can modify the default inputs (i.e., add or remove input tables, change the join direction, etc.) by selecting the combined table and modifying the input selections in the object inspector.
-
- Join direction - Whether to join the tables side-by-side (must have some rows in common) or up-and-down (must have some columns in common).
-
Non-matching rows/columns: The tables that you are merging might have row (or column) names that do not match. This option allows you to specify how to handle the non-matches.
- Keep all - Keep all rows from the tables. Rows that do not match the other tables will be blank.
- Matching only - Keep only the rows that are common between the tables.
-
Row names - If you wish to override the names of the rows in the new table you can type new names here, separating them with commas. These names will be applied to the rows, beginning at the top.
-
Column names - If you wish to override the names of the columns in the new table you can type new names here, separating them with commas. These names will be applied to the columns, beginning with the leftmost column.
- If one or more of the input tables contain multiple statistics, only the first statistic will be used. In this situation. a warning message will be displayed above the object inspector: