checkConflicts: Check for (potential) data format conflicts

View source: R/checkConflicts.R

checkConflictsR Documentation

Check for (potential) data format conflicts

Description

This function checks for potential data formatting conflicts that may produce errors or incorrect results when applying the expandMultiarmTrials function later on.

Usage

checkConflicts(.data,
               vars.for.id = c("study", "primary",
                               "Outc_measure",
                               "Time", "Time_weeks",
                               "sr_clinician"),
               .no.arms = "no.arms",
               .condition.specification = "Cond_spec",
               .group.indicator = "condition",
               .group.names = list("ig" = "ig",
                                   "cg" = "cg"),
               .groups.column.indicator = c("_trt1", "_trt2"),
               data.format = NULL)

Arguments

.data

Meta-analysis data stored as a data.frame, to be checked by the function.

vars.for.id

character vector, containing column names of all variables used to construct unique comparison IDs.

.no.arms

character, signifying the name of the variable containing the number of arms included in a study (typically 2).

.condition.specification

character, name of the column containing the specific condition in each trial arm. For multiarm trials, these conditions must be distinct (e.g. "cbt-guided" and "cbt-unguided").

.group.indicator

character, variable encoding if a row represents an intervention or control/reference arm.

.group.names

list, storing the name of the value in .group.indicator corresponding to the intervention group ("ig") and control group ("cg").

.groups.column.indicator

character. If the dataset is in wide format: a character vector with two elements, representing the suffix used to differentiate between the first and second treatment in a comparison.

data.format

character. Either "long" or "wide", depending on the format of the dataset in data. NULL by default, which lets the user define the format after the function has been called.

Value

The type of data returned by checkConflicts depends on the outcome of the evaluation. When no problems have been detected, the function simply returns the dataset provided in .data.

When (potential) formatting formatting issues have been detected, the function throws a message and returns the affected studies/data.frame columns. In particular, results are provided within a list of three objects:

  • allConflicts, a data.frame containing all affected rows, regardless of conflict type.

  • idConflicts, a data.frame containing rows with ID/number of arms conflicts.

  • cgConflicts, a data.frame containing rows with reference arm conflicts (there must be a unique control/reference group for each comparison).

The returned list has class checkConflicts.

Author(s)

Mathias Harrer mathias.h.harrer@gmail.com, Paula Kuper paula.r.kuper@gmail.com, Pim Cuijpers p.cuijpers@vu.nl

See Also

expandMultiarmTrials

Examples

## Not run: 
data("inpatients")
data("psyCtrSubset")

# Example 1: Use defaults and simply run checks
psyCtrSubset %>%
  checkDataFormat() %>%
  checkConflicts() -> result

# Example 2: Use defaults, run check and directly
# proceed expanding multiarm trials/calculating effects
inpatients %>%
  checkDataFormat() %>%
  checkConflicts() %>%
  expandMultiarmTrials() %>%
  calculateEffectSizes() -> result

# Example 3: Define custom IDs (example generates error)
vars.for.id = c("study", "primary",
                "Time", "Time_weeks")
psyCtrSubset %>%
  checkDataFormat() %>%
  checkConflicts(vars.for.id) %>%
  expandMultiarmTrials(vars.for.id) -> res

# Example 4: Wide format
data("psyCtrSubsetWide")
psyCtrSubsetWide %>%
  checkDataFormat() %>%
  checkConflicts()

# Example 4: Wide format; overrule default input prompt
checkConflicts(psyCtrSubsetWide,
               data.format = "wide")

## End(Not run)



MathiasHarrer/metapsyTools documentation built on May 1, 2022, 5:14 p.m.