Skip to content

Make tidy sliding play nicely with data frame inputs #55

Open
@ryantibs

Description

@ryantibs

Tidy sliding is pretty convenient. But in some applications, I might want to actually be sliding a function that takes an entire data frame rather than pass in individual columns as arguments.

For example, let's suppose my_fun() is a complicated function that I've written that acts on a whole data frame, whose signature is:

my_fun(df, args)

Then I could do:

x %>% 
  epi_slide(f = my_fun, args = my_args, n = 120, new_col_name = "fc")

But I could NOT easily do some tidy sliding, because there's currently no way to get the tidy eval thing I've written to understand "pass the sliding data frame". It only understands "pass these sliding variables".

Ideally, we'd code in some special variable name that epi_slide() (and analogously epix_slide()) understands and treats in a special way, say .cur_df (prefixing a dot so that it doesn't conflict with variable names in the environment) and then we could do:

x %>% 
  epi_slide(fc = my_fun(.cur_df, args = my_args), n = 120)

which is more intuitive/convenient for folks who like tidy code.

@lcbrooks @dajmcdon @jacobbien @elray1 what do you think? Anybody want to take a stab at implementing it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2low priorityenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions