Skip to content

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

@travis-leith

Description

@travis-leith

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.

Metadata

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