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

FR : add as.ts 'drop' argument #282

Open
arnaud-feldmann opened this issue Jul 25, 2022 · 1 comment
Open

FR : add as.ts 'drop' argument #282

arnaud-feldmann opened this issue Jul 25, 2022 · 1 comment

Comments

@arnaud-feldmann
Copy link

arnaud-feldmann commented Jul 25, 2022

library(tsibble)
tibble(value=1:12,key = "all", time = make_yearmonth(2000,1:12)) %>%
  as_tsibble(index = time, key = key) %>%
  as.ts
#>      Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
#> 2000   1   2   3   4   5   6   7   8   9  10  11  12

# Wanted : an arg to get this result

ts(matrix(1:12, dimnames = list(NULL, "all")), start = 2000, frequency = 12) %>%
  dput
#> structure(1:12, dim = c(12L, 1L), dimnames = list(NULL, "all"), tsp = c(2000, 
#> 2000.91666666667, 12), class = "ts")

Hi,
Would it be possible to add something something like a drop=FALSE arg to as.ts.tbl_ts that would always convert a tibble with a key to a mts ? I think that would allow smoother conversions.

Thanks,

Arnaud

@arnaud-feldmann
Copy link
Author

arnaud-feldmann commented Jul 25, 2022

Same thing for the other side of the conversion :

as_tsibble(ts(matrix(1:12, dimnames = list(NULL, "all")), start = 2000, frequency = 12))

Would be, I think, nicer, if as_tsibble.ts would be allowed not to drop the dimension of the ts. But it's less disturbing IMO as it is possible to force the call to as_tsibble.mts by modifying the class attribute of your ts

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

1 participant