Skip to content

select: incomplete documentation for usage of ! an - in combination with renaming columns #7699

@deschen1

Description

@deschen1

Following the discussion here: https://stackoverflow.com/questions/79695678/dplyrselect-rename-columns-and-negative-selection-at-the-same-time-doesnt-wor, the documentation of select would benefit from a bit more clarity, especially wrt:

  • mentioning the usage of ! vs. - as negative selectors (since both are possible to use, but - is not mentioned, nor is the difference in their behaviour)
  • describing of the order of selecting "commands", especially when someone wants to rename columns within select.
mtcars |>
  dplyr::select(test = mpg,
                -carb)

vs.

mtcars |>
  dplyr::select(-carb,
                test = mpg)

I do see why the first code leads to a one-column df with just the test column, but I don't understand why the second code does not yield the same result).

Somewhat related to #7017

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