dict_generate: Generate a variable dictionary for a survey

View source: R/dict_generate.R

dict_generateR Documentation

Generate a variable dictionary for a survey

Description

Generate a variable dictionary for a Qualtrics survey survey

Usage

dict_generate(
  surveyID,
  name = c("question_name", "easy_name"),
  block_pattern = NULL,
  block_sep = ".",
  preprocess = NULL,
  split_by_block = FALSE
)

Arguments

surveyID

String. Unique ID for the survey you want to download.

name

String. Which type of variable names to use in the dictionary, question_name for question names on Qualtrics, easy_name for easy names generated based on question text.

block_pattern

Function. A function that given the name of a survey block, returns a string to be appended to variable names in that block. Defaults to NULL.

block_sep

String. Seperator between variable names and block prefixes returned by block_pattern. Defaults to ".".

preprocess

Function. A function that given a dataframe with the column names as in a dictionary, does formatting for each column. Defaults to NULL.

split_by_block

Logical. If TRUE, the function returns a list with each element being the dictionary for a single survey block.

Value

A 'qualtdict' dataframe or a list of 'qualtdict' dataframes (depending on split_by_block.

Examples

## Not run: 

# Create a function for \code{block_pattern}
# that returns the first three letters of a string
block_pattern <- function(x) {
  substring(x, 1, 3)
}


mydict <- dict_generate("SV_4YyAHbAxpdbzacl",
  name = "easy_name",
  block_pattern = block_pattern,
  block_sep = ".",
  split_by_block = FALSE
)

## End(Not run)


lyh970817/qualtdict documentation built on April 8, 2023, 9:26 p.m.