
Strip Qualtrics secondary-header rows and re-type the columns
Source:R/data_check_helpers.R
data_strip_qualtrics_header.RdA 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.
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