Closed billdenney closed 3 years ago
Thanks for reporting this, it looks like a bug:
# options(rlang_backtrace_on_error = "full")
tryCatch(
hms::as_hms(as.difftime(1:3, units = "secs")),
error = identity
)
#> <error/vctrs_error_assert_ptype>
#> `x` must be a vector with type <double>.
#> Instead, it has type <integer>.
#> Backtrace:
#> 1. base::tryCatch(...)
#> 5. hms::as_hms(as.difftime(1:3, units = "secs"))
#> 6. vctrs::vec_cast(x, new_hms())
#> 8. hms:::vec_cast.hms.difftime(x = x, to = to, x_arg = x_arg, to_arg = to_arg)
#> 9. hms::new_hms(vec_data(x))
#> 10. vctrs::vec_assert(x, numeric())
Created on 2020-12-22 by the reprex package (v0.3.0)
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
This is related to tidyverse/dplyr#5343 in that the issue there is what made me find this issue. Otherwise, the issues are unrelated.
When a double vector with attributes is passed into
as_hms()
but nothms()
, it gives an error that does not indicate the actual problem. I believe that the actual problem is that there are attributes, and the message below does not indicate that. In my real example, I loaded a SAS dataset, and those always come with attributes that I always ignore.Created on 2020-06-19 by the reprex package (v0.3.0)