Skip to content

future_frame() fails on grouped data with one observation #108

Open
@spsanderson

Description

I have a script I run here: https://github.com/spsanderson/healthyverse_tsa

Today, there is only one record for my package TidyDensity. The record is below:

data_transformed_tbl %>% group_by(package) %>% filter(package == "TidyDensity")
# A tibble: 1 x 3
# Groups:   package [1]
  date       package     value_trans
  <date>     <chr>             <dbl>
1 2022-01-21 TidyDensity       0.179

When I try to use bind_rows to add a future_frame the process bombs out.

> data_transformed_tbl %>% 
  group_by(package) %>% 
  filter(package == "TidyDensity") %>% 
  bind_rows(future_frame(., .date_var = date, .length_out = horizon))

Error: Problem with `mutate()` column `nested.col`.
i `nested.col = purrr::map(...)`.
x error in evaluating the argument 'x' in selecting a method for function 'as_date': 'from' must be a finite number
i The error occurred in group 1: package = "TidyDensity".
Run `rlang::last_error()` to see where the error occurred.

Here is the rlang::last_error()

> rlang::last_error()
<error/dplyr:::mutate_error>
Problem with `mutate()` column `nested.col`.
i `nested.col = purrr::map(...)`.
x error in evaluating the argument 'x' in selecting a method for function 'as_date': 'from' must be a finite number
i The error occurred in group 1: package = "TidyDensity".
Backtrace:
  1. `%>%`(...)
 36. base::.handleSimpleError(...)
 37. dplyr:::h(simpleError(msg, call))
Run `rlang::last_trace()` to see the full context.

Here is the trance:

> rlang::last_trace()
<error/dplyr:::mutate_error>
Problem with `mutate()` column `nested.col`.
i `nested.col = purrr::map(...)`.
x error in evaluating the argument 'x' in selecting a method for function 'as_date': 'from' must be a finite number
i The error occurred in group 1: package = "TidyDensity".
Backtrace:
     x
  1. +-`%>%`(...)
  2. +-dplyr::bind_rows(., future_frame(., .date_var = date, .length_out = horizon))
  3. | \-rlang::list2(...)
  4. +-timetk::future_frame(., .date_var = date, .length_out = horizon)
  5. +-timetk:::future_frame.grouped_df(., .date_var = date, .length_out = horizon)
  6. | \-`%>%`(...)
  7. +-dplyr::group_by_at(., .vars = group_names)
  8. | \-dplyr:::manip_at(...)
  9. |   \-dplyr:::tbl_at_syms(.tbl, .vars, .include_group_vars = .include_group_vars)
 10. |     \-dplyr:::tbl_at_vars(tbl, vars, .include_group_vars = .include_group_vars)
 11. |       \-dplyr::tbl_vars(tbl)
 12. |         +-dplyr:::new_sel_vars(tbl_vars_dispatch(x), group_vars(x))
 13. |         | \-base::structure(...)
 14. |         \-dplyr:::tbl_vars_dispatch(x)
 15. +-tidyr::unnest(., cols = nested.col)
 16. +-dplyr::select(., -data)
 17. +-dplyr::mutate(...)
 18. +-dplyr:::mutate.data.frame(...)
 19. | \-dplyr:::mutate_cols(.data, ..., caller_env = caller_env())
 20. |   +-base::withCallingHandlers(...)
 21. |   \-mask$eval_all_mutate(quo)
 22. +-purrr::map(...)
 23. | \-timetk:::.f(.x[[i]], ...)
 24. |   \-timetk:::future_framer(...)
 25. |     +-timetk::tk_make_future_timeseries(...)
 26. |     \-timetk:::tk_make_future_timeseries.Date(...)
 27. |       \-`%>%`(...)
 28. +-lubridate::as_date(.)
 29. +-timetk:::tk_make_future_timeseries.yearmon(...)
 30. | \-timetk:::make_sequential_timeseries_regular_freq(...)
 31. |   +-base::seq(...)
 32. |   \-base::seq.default(...)
 33. |     \-base::stop("'from' must be a finite number")
 34. +-base::.handleSimpleError(...)
 35. | \-base:::h(simpleError(msg, call))
 36. \-base::.handleSimpleError(...)
 37.   \-dplyr:::h(simpleError(msg, call))
<error/simpleError>
error in evaluating the argument 'x' in selecting a method for function 'as_date': 'from' must be a finite number

Data is attached.

cran_logs.csv

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions