-
Notifications
You must be signed in to change notification settings - Fork 276
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
yet another form of nothing for type-specific map_*() to handle #181
Comments
This is a duplicate of #173 |
I don't entirely understand why this is a duplicate. @hadley library(purrr)
x <- list("a" = list("b" = character()))
x[[c("a", "b")]]
#> character(0)
x %>% map("b")
#> $a
#> character(0)
x %>% map_chr("b")
#> Error: Result 1 is not a length 1 atomic vector |
Because map_chr calls [[. It makes sense to me anyway, so I'll remember |
Closed issue, but leaving for anyone who is cleaning up JSON and stumbles into this same problem - I resolved this by writing a wrapper around @jennybc's great workaround above:
And replaced my offending |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Continuing our exploration of nothingness (#110).
It seems type specific map functions should be willing to cope with length zero elements and treat them as null/absent.
This seems to get the job done for the time being:
FYI: inspired by an actual list that came from JSON, that came from the Twitter API.
The text was updated successfully, but these errors were encountered: