Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all_surveys Error When Survey Name is Blank #212

Closed
Scott123456 opened this issue Apr 7, 2021 · 3 comments
Closed

all_surveys Error When Survey Name is Blank #212

Scott123456 opened this issue Apr 7, 2021 · 3 comments

Comments

@Scott123456
Copy link

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.

@juliasilge
Copy link
Collaborator

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.

@dsen6644
Copy link
Contributor

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.

@jmobrien
Copy link
Collaborator

I noticed that NULL's now no longer cause bind_rows() to fail; they just become NA's. I went looking for this to remember what was up--this is still open, but it looks like it's no longer relevant? The underlying issue was fixed not long after in dplyr: tidyverse/dplyr#5502

I tested having a NULL survey name, and it's fine now. Could open up options to simplify other code as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants