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

Feature request: Add a tidyselect function to select everything except index and index_by columns #314

Open
travis-leith opened this issue Jul 11, 2024 · 0 comments

Comments

@travis-leith
Copy link

It would be useful to have a function that selects all data columns (excluding index and any columns created by index_by).
For example, I am converting some tibble based code into tsibble based code. My current code looks like this

data |>
mutate(across(-dtm, ~ log(.x / lag(.x))))

But I have to know what the index column is called. Would be nice to be able to write generic code that takes a tsibble and knows what to do with it without knowing what the index is called. It's been a while since I used xts but I seem to recall that the index is not a normal column in xts and so such generic code is natural.

The following does not work

data |>
mutate(across(everything(), ~ log(.x / lag(.x))))

because everything() includes the index column.

What I am proposing is one or both of the following options

data |>
mutate(across(-index_column(), ~ log(.x / lag(.x))))
data |>
mutate(across(data_columns(), ~ log(.x / lag(.x))))

with perhaps more thought given to the actual names of these functions.

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