qualtRics
qualtRics copied to clipboard
`all_surveys` Error When Survey Name is Blank
When running the all_surveys
function, I get an error due to a NULL
survey name. The error occurs when the function tries to bind_rows(master)
at the end. It cannot complete the bind_rows
if there is a null value in any of the elements. :/
I was able to work around it by changing the survey name in Qualtrics online. However, it took me a couple hours to figure out the issue. It's kind of crazy that Qualtrics returns an element with a null value (or even allows a survey to have no name), but it does and it breaks the expected behavior of the function.
One proposed solution is to check all elements for null values before appending or binding and replacing them with NA. Though I haven't been able to test this solution yet.
Oh, that sounds super frustrating, wow! 🥴 Your proposed solution sounds like a good thing to try here in the R package to get around the behavior in the API.
We had to deal with NULL
values frequently when working with mailing lists and distribution data. Our solution was to avoid using dplyr::bind_rows
due to the issue stated above, that null values will throw errors when binding is attempted.
Our solution was to explicitly call the list values using purrr:map_*
and allow the .default
argument to coerce nulls into NA
values.
So rather than
d <- bind_rows(master)
We would do something like
x <- tibble::tibble(id = purrr::map_chr(master, "id", .default = NA_character_),
name = purrr::map_chr(master, "id", .default = NA_character_),
ownerId = purrr::map_chr(master, "id", .default = NA_character_),
lastModified = lubridate::ymd_hms(purrr::map_chr(master, "id", .default = NA_character_)),
creationDate = lubridate::ymd_hms(purrr::map_(master, "id", .default = NA_character_)),
isActive = purrr::map_lgl(master, "id", .default = NA_real_))
The code is definitely less elegant and less compact, but it's explicit and prevents issues with NULL
values.