-
Notifications
You must be signed in to change notification settings - Fork 420
Closed
Labels
featurea feature request or enhancementa feature request or enhancementrectangling 🗄️converting deeply nested lists into tidy data framesconverting deeply nested lists into tidy data frames
Description
It seems that drop_na()'s dependency on stats::complete.cases is tripping it up when any list-cols are present:
library(tidyverse)
library(purrr)
set.seed(1)
# Give mtcars a list-col and some NAs
mtcars_nas <-
mtcars %>%
rownames_to_column() %>%
mutate(LIST_COL = map(mpg, ~sample(LETTERS, nchar(.x)))) %>%
mutate(mpg = sample(c(mpg, rep(NA, 32)), n(), replace = TRUE)) %>%
select(rowname, mpg, LIST_COL) %>%
as_tibble
mtcars_nas
#> # A tibble: 32 × 3
#> rowname mpg LIST_COL
#> <chr> <dbl> <list>
#> 1 Mazda RX4 NA <chr [2]>
#> 2 Mazda RX4 Wag 21.4 <chr [2]>
#> 3 Datsun 710 15.0 <chr [4]>
#> 4 Hornet 4 Drive 16.4 <chr [4]>
#> 5 Hornet Sportabout NA <chr [4]>
#> 6 Valiant 19.7 <chr [4]>
#> 7 Duster 360 NA <chr [4]>
#> 8 Merc 240D 15.2 <chr [4]>
#> 9 Merc 230 10.4 <chr [4]>
#> 10 Merc 280 NA <chr [4]>
#> # ... with 22 more rows
# Try to drop the incomplete rows - fails
mtcars_nas %>% tidyr::drop_na()
#> Error in stats::complete.cases(data): invalid 'type' (list) of argumentCan you add a check to drop_na() to override this behavior?
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancementrectangling 🗄️converting deeply nested lists into tidy data framesconverting deeply nested lists into tidy data frames