You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if there was a workaround for length recycling in purrr.
for
li<-list(list(x=1, y=2), list(x=2, w=3), list(w=23, y=4))
map(li, "w")
[[1]]
NULL
[[2]]
3
[[3]]
23
map_int(li, "w")
Errorin`map_int()`:
ℹ Inindex:1.Causedbyerror:!Resultmustbelength1, not0.# The workaround I used is
map_int(li, \(x) x$w %||% NA)
[[1]]
NULL
[[2]]
3
[[3]]
23# but it is not as elegant as the first solution
Edit: there is also dplyr::coalesce(list, list(NA)), but again, not as elegent.
The text was updated successfully, but these errors were encountered:
I was wondering if there was a workaround for length recycling in purrr.
for
Edit: there is also
dplyr::coalesce(list, list(NA))
, but again, not as elegent.The text was updated successfully, but these errors were encountered: