checkDataFormat: Check data format

View source: R/checkDataFormat.R

checkDataFormatR Documentation

Check data format

Description

This is a function to check the format of meta-analysis data with class data.frame for its further applicability to the expandMultiarmTrials function.

Usage

checkDataFormat(data,
           must.contain = c("study", "condition",
                            "Cond_spec", "is.multiarm",
                            "no.arms", "multiple_arms",
                            "Outc_measure", "Time", "primary",
                            "Time_weeks", "sr_clinician"),
           variable.contains = list("condition" = c("ig", "cg"),
                                    "is.multiarm" = c(0,1)),
           variable.class = list("study" = "character",
                                 "condition" = "character",
                                 "Cond_spec" = "character",
                                 "is.multiarm" = "numeric",
                                 "no.arms" = "numeric",
                                 "multiple_arms" = "character",
                                 "primary" = "numeric",
                                 "Time" = "character",
                                 "Time_weeks" = "character",
                                 "sr_clinician" = "character",
                                 "Post_M" = "numeric",
                                 "Post_SD" = "numeric",
                                 "Post_N" = "numeric",
                                 "Rand_N" = "numeric",
                                 "Improved_N" = "numeric",
                                 "Change_m" = "numeric",
                                 "Change_SD" = "numeric",
                                 "Change_N" = "numeric"),
           groups.column.indicator = c("_trt1", "_trt2"),
           data.format = NULL)

Arguments

data

Meta-analysis data stored as a data.frame.

must.contain

character vector, containing all the variable names the data set should contain.

variable.contains

list, defining which values should only be contained in a variable.

variable.class

list, defining the required data class for some or all variables. If the class differs, the function will try to convert the variable to the desired class.

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.

Details

The function ckecks if:

  • the data set contains all relevant variables

  • variables contain desired values only and

  • variables are of desired type (if not, it tries to convert them).

If the dataset format is wide, please specify all variable/column names without the group indicator suffix (e.g. for "Cond_spec_trt1" and "Cond_spec_trt2", simply use "Cond_spec").

Value

checkDataFormat returns messages that specify if input variables, values and classes of the variables are as defined.

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")

# Example 1: Check data with default arguments
checkDataFormat(inpatients)

#Example 2: Check for specified variables and corresponding values and classes
checkDataFormat(inpatients,
                must.contain = c("study", "condition",
                                 "primary", "year"),
                variable.contains = list("condition" = c("ig","cg")),
                variable.class = list(study = "character",
                                      no.arms = "numeric"))

#Example 3: Convert variable class as predefined
checkDataFormat(inpatients,
                must.contain = c("primary", "study"),
                variable.class = list(primary = "integer"))

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

## End(Not run)



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