Skip to contents

Identifies and merges tables that share the same DOI or, if DOI is missing, the same BibTex entry. If tables do not have the same structure, only those with identical structures will be merged. This function performs several consistency checks before merging, and prompts the user for confirmation if inconsistencies are found.

Usage

irw_merge(table_name, add_source_column = TRUE)

Arguments

table_name

A character string specifying the name of the table to find merge candidates for.

add_source_column

A boolean value indicating whether to add the source_table column to the merged table (default is TRUE). This column keeps track of the original source of each row.

Value

A merged data frame containing all tables with the same DOI or BibTex, or NULL if no merge candidates are found.

Details

irw_merge() performs the following checks before proceeding with the merge:

  1. Number of Respondents Check:

    • The function checks if the number of respondents is consistent across all tables.

    • If the number of respondents is consistent, the merge proceeds.

    • If the number of respondents is inconsistent across tables, a WARNING message is displayed:

      === WARNING ===
      The number of respondents (N) is not consistent across tables.
      Merging tables with inconsistent N respondents may require human judgment.

  2. ID Consistency Check:

    • Checks if all tables share the same set of IDs.

    • Checks if the IDs form a strict sequence (e.g., 1, 2, 3, ...).

    • If IDs are not consistent across tables, a NOTE message is displayed:

      === NOTE: ===
      - IDs do not match across tables.
      - IDs are sequential (1...n). You may need to manually verify the IDs,
        as there could be multiple studies with different subjects, where IDs
        are the same in both studies.

  3. Item Column Overlap Check:

    • Verifies that there is no overlap of item columns across tables.

    • If overlapping items are found, a NOTE message is displayed:

      === NOTE: ===
      - There are items that overlap across tables.