Skip to contents

A Qualtrics "use choice text" export has extra header rows (human question text, then an ImportId JSON row) directly under the machine-name header. read.delim reads the machine names as the header but keeps those two rows as the first data rows, which forces every column to character. This drops any leading rows that look like Qualtrics header rows (see .qualtrics_is_header_row) and coerces columns that are now fully numeric back to numeric, so the rest of data_check types the file correctly.

Usage

data_strip_qualtrics_header(df, max_strip = 2L)

Arguments

df

a data.frame read from a Qualtrics export (machine names as header)

max_strip

maximum number of leading rows to consider stripping

Value

the cleaned data.frame (unchanged if no header rows are found).

Examples

# a Qualtrics export: question text and import ids above the answers
df <- data.frame(
  StartDate = c("Start Date", '{"ImportId":"startDate"}', "2024-01-01", "2024-01-02"),
  EndDate = c("End Date", '{"ImportId":"endDate"}', "2024-01-01", "2024-01-02"),
  Progress = c("Progress", '{"ImportId":"progress"}', "100", "100"),
  ResponseId = c("Response ID", '{"ImportId":"_recordId"}', "R_1", "R_2"),
  Q1 = c("How old are you?", '{"ImportId":"QID1"}', "21", "34"))
data_strip_qualtrics_header(df)
#>    StartDate    EndDate Progress ResponseId Q1
#> 1 2024-01-01 2024-01-01      100        R_1 21
#> 2 2024-01-02 2024-01-02      100        R_2 34