Skip to content
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

Duration columns #1327

Closed
tvatter opened this issue Nov 17, 2021 · 1 comment
Closed

Duration columns #1327

tvatter opened this issue Nov 17, 2021 · 1 comment

Comments

@tvatter
Copy link

tvatter commented Nov 17, 2021

Hi,

I am aware of #549 and #1037, but it does not really address my problem. Additionally, I already filed a similar bug report on the lubridate repo as I am unsure whether the responsibility to handle the following issue falls on readr or lubridate...

Here's a regex of my issue:

df <- tibble(x = duration(1, "years"))     # x is a duration
tmp <- tempfile(); write_csv(df, tmp)    # write the df to file
df2 <- read_csv(tmp)                           # x is now a character which can't be easily coerced

The main issue is that as.duration(as.character(duration(1, "years")))) returns NA because the parser from the duration class is designed with a different purpose in mind.

Now, I get that one could just convert a duration as a numeric before writing, via mutate(across(where(is.duration), as.numeric)).
But while I understand that readr can't handle every class out there, I was expecting the duration class, being provided by a tidyverse package, to be handled "properly" by write_csv.

Thoughts?

@vspinu
Copy link
Member

vspinu commented Jan 12, 2022

Fixed in tidyverse/lubridate#1005

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants