Skip to content

Auto rename in summarise_by_time #168

Open
@sdbentrup

Description

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)

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