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

What’s the preferred syntax for excluding columns when using select? #463

Open
briandk opened this issue Dec 10, 2022 · 1 comment
Open

Comments

@briandk
Copy link

briandk commented Dec 10, 2022

In the guide on selecting columns, you use the tilde (~) operator before a column name to indicate that column should be excluded from the selection:

You can remove a column from the data by putting a tilde operator (~) in front of it.

penguins >> select(~_.body_mass_g, ~_.sex, ~_.year)

But, later on down that page in the pandas comparison, you use a dash (or minus sign?) before the column name:

# keep all *except* cyl column
mtcars >> select(-_.cyl)

Is one notation preferred?

@machow
Copy link
Owner

machow commented Dec 10, 2022

Hey, I would lean towards ~. I added it to match dplyr's switch from - to !, but old habits die hard 😬.

Let's use this issue to track changing the docs to consistently use ~.

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

2 participants