Skip to content

Commit db91195

Browse files
committed
clarify missingness procedure in is_selected docs
1 parent 338af6c commit db91195

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

facebook/delphiFacebook/R/variables.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ split_options <- function(column) {
1919

2020
#' Test if a specific selection is selected
2121
#'
22+
#' Checking whether a specific selection is selected in either "" (empty
23+
#' string) or `NA` responses will produce `NA`s.
24+
#'
2225
#' @param vec A list whose entries are character vectors, such as c("14", "15").
2326
#' @param selection one string, such as "14"
2427
#' @return a logical vector; for each list entry, whether selection is contained
@@ -28,8 +31,10 @@ is_selected <- function(vec, selection) {
2831
vec,
2932
function(resp) {
3033
if (length(resp) == 0 || all(is.na(resp))) {
31-
# All our selection items include "None of the above" or similar, so
32-
# treat no selection the same as missingness.
34+
# Qualtrics files code no selection as "" (empty string), which is
35+
# parsed by `read_csv` as `NA` (missing) by default. Since all our
36+
# selection items include "None of the above" or similar, treat both no
37+
# selection ("") or missing (NA) as missing, for generality.
3338
NA
3439
} else {
3540
selection %in% resp

0 commit comments

Comments
 (0)