automateDataPreparation: Automate Data Preparation using Functions from Package...

Description Usage Arguments Value Author(s) Examples

View source: R/automateDataPreparation.R

Description

This function facilitates automated data preparation and wraps most functions from the eatPrep package.

Usage

1
2
3
4
5
6
7
8
9
automateDataPreparation(datList = NULL, inputList, path = NULL, 
    readSpss, checkData,  mergeData, recodeData, recodeMnr = FALSE,
    aggregateData, scoreData, writeSpss, collapseMissings = FALSE, 
    filedat = "mydata.txt", filesps = "readmydata.sps", breaks=NULL, 
    nMbi = 2, rotation.id = NULL, suppressErr = FALSE, recodeErr = "mci",
    aggregatemissings = NULL, rename = TRUE, recodedData = TRUE, 
    correctDigits=FALSE, truncateSpaceChar = TRUE, newID = NULL, oldIDs = NULL, 
    missing.rule = list(mvi = 0, mnr = 0, mci = NA, mbd = NA, mir = 0, mbi = 0), 
    verbose=FALSE)

Arguments

datList

A list of data frames (see data(inputDat)). If NULL, readSPSS has to be TRUE. In this case, the function attempts to read SPSS .sav files.

inputList

A list of data frames containing neccessary information for data preparaton (see data(inputList) for details).

path

A character vector containing the path required by readSpss (source of SPSS files) and writeSpss. Default is the current R working directory.

readSpss

Logical: If TRUE, the function readSpss will be called.

checkData

Logical: If TRUE, the function checkData will be called.

mergeData

Logical: If TRUE, the function mergeData will be called.

recodeData

Logical: If TRUE, the function recodeData will be called.

recodeMnr

Logical: If TRUE, the function mnrCoding will be called.

aggregateData

Logical: If TRUE, the function aggregateData will be called.

scoreData

Logical: If TRUE, the function scoreData will be called.

collapseMissings

Logical: If TRUE, the function collapseMissings will be called and a data frame with recoded missing values according to argument missing.rule will be returned.

writeSpss

Logical: If TRUE, the function writeSpss will be called.

filedat

a character string containing the name of the output data file for writeSpss.

filesps

a character string containing the name of the output syntax file for writeSpss.

breaks

Numeric vector passed on to function mnrCoding containing the number of blocks after which mbi shall be recoded to mnr, e.g., c(1,2) to specify breaks after the first and second block. numeric vector (argument used by ).

nMbi

Numeric vector of length 1 passed on to function mnrCoding containing the number of mbi-Codes required at the end of a block to code mnr. Needs to be >=1..

rotation.id

Character vector of length 1 passed on to function mnrCoding indicating the name of the rotation indicator (e.g. “booklet”) in the dataset.

suppressErr

Logical passed on to function aggregateData indicating whether aggregated cells with err should be recoded to another value..

recodeErr

Character vector of length 1 passed on to function aggregateData indicating to which err should be recoded. This argument is only evaluated when suppressErr = TRUE

.

missing.rule

A named list with definitions how to recode the different types of missings in the dataset. If writeSPSS = TRUE, missing values will be recoded to 0 or NA prior to writing the SPSS dataset. See collapseMissings for supported missng values.

aggregatemissings

A symmetrical n x n matrix or a data frame from inputList$aggrMiss passed on to function aggregateData with information on how missing values should be aggregated. If no matrix is given, the default will be used. See 'Details' in aggregateData.

rename

Logical passed on to function aggregateData indicating whether units with only one subunit should be renamed to their unit name? Default is FALSE.

recodedData

Logical passed on to function aggregateDataindicating whether colnames in dat are the subunit names (as in subunits$subunit) or recoded subunit names (as in subunits$subunitRecoded). Default is TRUE, meaning that colnames are recoded subitem names.

correctDigits

logical. See readSpss.

truncateSpaceChar

logical. See readSpss.

newID

A character string containing the case IDs name in the final data frame. Default is ID or a character string specified in inputList$newID.

oldIDs

A vector of character strings containing the IDs names in the original SPSS datasets. Default is as specified in inputList$savFiles.

verbose

Logical: If TRUE, progress and additional information is printed.

Value

A data frame resulting from the final data preparation step.

Author(s)

Karoline Sachse

Examples

1
2
3
4
5
6
7
8
data(inputList)
data(inputDat)
preparedData <- automateDataPreparation(inputList = inputList, 
    datList = inputDat,	path = "c:/temp/test_eat", 
    readSpss = FALSE, checkData = TRUE,	mergeData = TRUE, 
    recodeData = TRUE, recodeMnr = TRUE, breaks = c(1,2),
    aggregateData = TRUE, scoreData = TRUE, 
    writeSpss = FALSE, verbose = TRUE)

eatPrep documentation built on May 2, 2019, 5:20 p.m.