How can I make my dates maintain their type in after a purrr::cross_df()?
It seems that my date type changes after a cross_df() how can I prevent this or change it back?
library(tidyverse)
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:base':
#>
#> date
# make sequence of 24 hours
hrs <- seq(1,24,1)
# make sequence of dates given date range
date <- seq.Date(as.Date("2018-08-02"), as.Date("2018-11-26"), "1 day")
# cross hours with dates
hrs_dates <- list(hrs = hrs, date = date)
str(hrs_dates)
#> List of 2
#> $ hrs : num [1:24] 1 2 3 4 5 6 7 8 9 10 ...
#> $ date: Date[1:117], format: "2018-08-02" "2018-08-03" ...
hrs_dates %>% cross_df() %>% str
#> Classes 'tbl_df', 'tbl' and 'data.frame': 2808 obs. of 2 variables:
#> $ hrs : num 1 2 3 4 5 6 7 8 9 10 ...
#> $ date: num 17745 17745 17745 17745 17745 ...
Created on 2018-11-28 by the reprex package (v0.2.1)