File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -452,7 +452,11 @@ process_qsf <- function(path_to_qsf,
452
452
qdf <- rbind(qdf , other_text_items )
453
453
qdf $ response_options [qdf $ question_type == " Text" ] <- NA
454
454
455
-
455
+ # Drop occasional start and end square brackets from matrix response options.
456
+ qdf <- qdf %> %
457
+ mutate(
458
+ response_options = map_chr(response_options , ~ remove_brackets(.x ))
459
+ )
456
460
457
461
# Quality checks
458
462
stopifnot(length(qdf $ variable ) == length(unique(qdf $ variable )))
@@ -467,6 +471,14 @@ process_qsf <- function(path_to_qsf,
467
471
return (qdf %> % rename(version = wave ))
468
472
}
469
473
474
+ remove_brackets <- function (response_set ) {
475
+ if ( ! is.na(response_set ) && startsWith(response_set , " [" ) && endsWith(response_set , " ]" ) ) {
476
+ str_sub(response_set , 2 , - 2 )
477
+ } else {
478
+ response_set
479
+ }
480
+ }
481
+
470
482
# ' Append the parsed and formatted info from the QSF to the existing codebook
471
483
# '
472
484
# ' @param qdf dataframe containing parsed QSF data
@@ -511,7 +523,7 @@ add_qdf_to_codebook <- function(qdf,
511
523
qdf <- qdf %> % select(- replaces )
512
524
}
513
525
}
514
-
526
+
515
527
# Using rbind here to raise an error if columns differ between the existing
516
528
# codebook and the new wave data.
517
529
# Sort so that items with missing question_type (non-Qualtrics fields) are at the top.
You can’t perform that action at this time.
0 commit comments