util_fbs_parent_v7dat: util_fbs_parent_v7dat: Process raw Qualtrics visit 7 data for...

View source: R/util_fbs_parent_v7dat.R

util_fbs_parent_v7datR Documentation

util_fbs_parent_v7dat: Process raw Qualtrics visit 7 data for the parent (1-year follow-up)

Description

This function loads the .sav raw data file for the parent visit 7 data that was collected via Qualtrics at 1-year follow-up and cleans the data. Cleaning the data involves: 1) extracting all variable descriptions, 2) selecting relevant data columns, 3) removing all practice events (e.g., 999) 4) re-ordering and re-name data columns 5) general fixes to variable labels (remove ' - 1') 6) fix variables with 99 issue for 'prefer not to answer' 7) reformatting dates to be appropriate and computer readable: YYYY-MM-DD 8) re-calculate manual variables 9) re-ordering factor levels to start with value 0 10) random fixes to factor level names and variable descriptions

Usage

util_fbs_parent_v7dat(file_pattern, data_path)

Arguments

file_pattern

string with the pattern to search for to find the raw data file. The pattern must contain respondent and visit number (e.g., for files from parent visit 1, would enter 'Parent_V1').

data_path

(optional) the full path to the directory where the raw Qualtrics database are saved, EXCLUDING the .sav file name (e.g., '.../b-childfoodlab_Shared/Active_Studies/RO1_Brain_Mechanisms_IRB_5357/Participant_Data/untouchedRaw/Qualtrics_Raw/'). If NOT entered, will assume the database is saved in the working directory.

Details

The databases MUST follow the naming convention: Parent_V7_Home_YYYY-MM-DD.sav

Value

A list containing: 1) data: data.frame with raw, cleaned data from parent visit 7 Qualtrics; 2) dict: all variable descriptions; 3) pna_data: data.frame marking participants who 'prefered not to answer' (pna) specific questions; and 4) pna_dict: all variable descriptions for pna_data

Examples

#if in same working directory as data:
p_v7_dat <- util_fbs_parent_v7dat('Parent_V7')

## Not run: 
#file_pattern must be a string. The following will not run:
p_v7_dat <- util_fbs_parent_v7dat(Parent_V7)

#file_pattern must have the respondent ('Parent') and visit number ('V1'). If just enter 'Parent', the script will not run because it will return multiple files for different parent visits. The following will not run:
p_v7_dat <- util_fbs_parent_v7dat('Parent')

## End(Not run)



alainapearce/kellertools documentation built on Feb. 25, 2024, 7:16 a.m.