Tables - Merge Two or More Tables

From Q
Jump to: navigation, search

Merges tables with matching row or column names. The merged table is an R Output and will not run any significance testing.

How to Merge Two or More Tables

  1. Add the object:
    1. In Displayr: Insert > More > Tables > Merge Two or More Tables
    2. In Q: Create > Tables > Merge Two or More Tables
  2. In Inputs > Tables, specify the tables to merge.
  3. Use Inputs > Join Direction to specify how the tables should be merged.

Example

The table below merges three tables, Brand Awareness, Top 2 Box Brand Attitude, and Preferred Cola using the side-by-side join direction.

An example of a merged table with three input tables.

Options

The options in the Object Inspector are organized into two tabs: Inputs and Properties.

Inputs

Tables: The tables to merge.

Join direction: Whether to join the tables by side-by-side (must have some rows in common) or up-and-down (must have some columns in common).

Handle 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.

Properties

This tab contains options for formatting the size of the object, as well as the underlying R code used to create the visualization, and the JavaScript code use to customize the Object Inspector itself (see Object Inspector for more details about these options). Additional options are available by editing the code.

More Information

See also

This function can handle joining many tables but only has limited options for handling non-matching labels. If you want to merge two tables and have greater control over non-matching labels, see Tables - Merge Two Tables.

Code

form.setHeading("Merge Tables")
form.dropBox({
    name: "tablesinput",
    label: "Tables",
    types: ["table", "RItem:matrix,array,data.frame,table"],
    multi: true
})
form.comboBox({
    name: "joindirinput",
    label: "Join direction",
    alternatives: ["Side-by-side", "Up-and-down"]
})
form.comboBox({
    name: "nonmatchinginput",
    label: "Handle non-matching rows/columns",
    alternatives: ["Keep all", "Matching only"],
    default_value: "Keep all",
    required: false
})
library(flipTables)

merged <- MergeTables(tables = tablesinput, direction = QInputs(joindirinput), nonmatching = QInputs(nonmatchinginput))