Reproducible example:
library(dplyr)
library(tidyr)
library(lubridate)
df1 <- seq(from = as.Date('2017-01-01'), to = as.Date('2017-01-10'), by = "1 day") %>%
list() %>%
data_frame(x = .)
df2 <- seq(from = as.Date('2017-01-01'), to = as.Date('2017-01-10'), by = "1 day") %>%
as.integer() %>%
list() %>%
data_frame(x = .)
Using the above, I am unable to unnest df1 but can get around it by coercing dates to integers and then back to dates.
> unnest(df1)
Error: Each column must either be a list of vectors or a list of data frames [x]
> unnest(df2) %>% mutate(x = as_date(x))
# A tibble: 10 x 1
x
<date>
1 2017-01-01
2 2017-01-02
3 2017-01-03
4 2017-01-04
5 2017-01-05
6 2017-01-06
7 2017-01-07
8 2017-01-08
9 2017-01-09
10 2017-01-10
Below is my sessionInfo():
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux
Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] bindrcpp_0.2 lubridate_1.7.2 tidyr_0.8.0 dplyr_0.7.4
loaded via a namespace (and not attached):
[1] Rcpp_0.12.15 utf8_1.1.3 crayon_1.3.4 assertthat_0.2.0 R6_2.2.2 magrittr_1.5
[7] pillar_1.1.0 cli_1.0.0 stringi_1.1.6 rlang_0.1.6 rstudioapi_0.7 tools_3.4.3
[13] stringr_1.2.0 glue_1.2.0 purrr_0.2.4 yaml_2.1.16 compiler_3.4.3 pkgconfig_2.0.1
[19] tidyselect_0.2.3 bindr_0.1 tibble_1.4.2
Reproducible example:
Using the above, I am unable to unnest
df1but can get around it by coercing dates to integers and then back to dates.Below is my
sessionInfo():