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

Error in vec_slice() when printing df #1738

Closed
alberto-agudo opened this issue Oct 21, 2022 · 1 comment
Closed

Error in vec_slice() when printing df #1738

alberto-agudo opened this issue Oct 21, 2022 · 1 comment

Comments

@alberto-agudo
Copy link

alberto-agudo commented Oct 21, 2022

I am using lubridate fast_strptime function to convert a character vector from a DataFrame into a Date vector within the same DataFrame.

This is the DataFrame:

Date Temperature_High
10/2/2022 61.5 °F
10/3/2022 65.8 °F
10/4/2022 65.4 °F
10/6/2022 64.7 °F
10/7/2022 61.5 °F
10/8/2022 61.5 °F
10/9/2022 61.3 °F
10/10/2022 59.3 °F
10/11/2022 60.8 °F
10/12/2022 60.8 °F
10/13/2022 63.3 °F
10/14/2022 59.1 °F
10/15/2022 58.6 °F
10/16/2022 57.5 °F
10/17/2022 61.1 °F
10/18/2022 61.8 °F
10/19/2022 57.5 °F
10/20/2022 63.1 °F

In order to transform it, I use:

df$Date <- lubridate::fast_strptime(df$Date, format = "%m/%d/%Y")

This doesn't return any error. Likewise, if I run the RHS operation on its own it returns a Date vector properly formatted.

However, when I execute df after that operation to see its contents, I get the following error:

Error in `vec_slice()`:
! Column `isdst` (size 1) must match the data frame (size 18).
ℹ In file slice.c at line 188.
ℹ Install the winch package to get additional debugging info the next time you get this error.
ℹ This is an internal error that was detected in the vctrs package.
  Please report it at <https://github.com/r-lib/vctrs/issues> with a reprex and the full backtrace.
Backtrace:
     ▆
  1. ├─base (local) `<fn>`(x)
  2. ├─pillar:::print.tbl(x)
  3. │ └─pillar:::print_tbl(...)
  4. │   ├─base::writeLines(...)
  5. │   ├─base::format(...)
  6. │   └─pillar:::format.tbl(...)
  7. │     └─pillar:::format_tbl(...)
  8. │       └─pillar::tbl_format_setup(...)
  9. │         ├─pillar:::tbl_format_setup_dispatch(...)
 10. │         └─pillar:::tbl_format_setup.tbl(...)
 11. │           └─pillar:::df_head(x, n)
 12. │             └─pillar:::vec_head(as.data.frame(x), n)
 13. │               └─vctrs::vec_slice(x, seq_len(n))
 14. └─rlang:::stop_internal_c_lib(...)
 15.   └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)

R version: 4.2.1
Lubridate version: 1.8.0
Tidyverse version: 1.3.2

@DavisVaughan
Copy link
Member

This is tidyverse/lubridate#1044 and was fixed in the dev version of lubridate.

Until that is released, this should work

df$Date <- as.POSIXct(lubridate::fast_strptime(df$Date, format = "%m/%d/%Y"))

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

2 participants