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

Auto rename in summarise_by_time #168

Open
sdbentrup opened this issue Jan 9, 2025 · 0 comments
Open

Auto rename in summarise_by_time #168

sdbentrup opened this issue Jan 9, 2025 · 0 comments

Comments

@sdbentrup
Copy link

When doing time series analysis and summarization, I like to have the name of the time variable include the interval, e.g. "sales_date_month" instead of "sales".

It might be useful to add functionality to automatically rename the .date_var in summarise_by_time like in e.g. pivot_wider(names_prefix = "") wherein a rename is passed the .by argument from summarise_by_time, also with an option to not rename.

As an example, the outcome would be the same as:
library(tidyverse)
library(timetk)

FANG %>%
group_by(symbol) %>%
summarise_by_time(
.date_var = date,
.by = "quarter",
volume = sum(volume)
) %>%
rename(quarter = date)

Thanks for considering and for the super-useful R package!

with the option to glue the .by to the .date_var, analogous to:

FANG %>%
group_by(symbol) %>%
summarise_by_time(
.date_var = date,
.by = "quarter",
volume = sum(volume)
) %>%
rename(quarter_date = date)

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