fix_ids: Fix Participant IDs

View source: R/questionnaire_tools.R

fix_idsR Documentation

Fix Participant IDs

Description

This function first removes the prefix specified in prefix (if found) and then converts all columns in pid_cols to numeric. It then takes the first non-NA value found, using column order in pid_cols for priority. It returns a vector of ids, with include_prefix prepended if supplied. This assumes x is a data.table.

Usage

fix_ids(x, pid_cols, prefix = NULL, format_ids = FALSE)

Arguments

x

A data.frame or data.table. Can be the whole table returned by get_survey_data.

pid_cols

A character vector of column names in order of priority. x does not need to include all columns in pid_cols.

prefix

A regular expression that will be removed prior to conversion to numeric.

format_ids

is either FALSE or an expression understood by sprintf used to format the resulting IDs

Value

A numeric or character vector of ids.


jflournoy/scorequaltrics documentation built on April 29, 2022, 9:17 p.m.