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

Banning the $-sign and brackets needs correcting #34

Open
dmonder opened this issue Aug 8, 2022 · 1 comment
Open

Banning the $-sign and brackets needs correcting #34

dmonder opened this issue Aug 8, 2022 · 1 comment

Comments

@dmonder
Copy link

dmonder commented Aug 8, 2022

I see two problems in the section titled Banning the $-sign and brackets (https://github.com/matloff/TidyverseSkeptic#case-study--tidys-banning-the--sign-and-brackets).

In the first example, you include an extra assignment in the Tidy version that is not in the base-R version. I would change the Tidy version to this:

loans <- openintro::loans_full_schema %>%
  mutate(bankruptcy = if_else(public_record_bankrupt >= 1, "Yes", "No")) %>%
  filter(annual_income >= 10)

This results in a comparable version to the base-R version.

As for the second example, the Tidy version can be simplified to the following since you are already using the magrittr package. This is only slightly more complicated than the base-R version and not near as complicated as the current example.

x <- c(5,12,13,1)

x %>% extract(. > 8)
@matloff
Copy link
Owner

matloff commented Mar 11, 2023

The Tidy code in my essay is not mine; it's from the article written by prominent Tidy proponents.

Interesting point about extract(), though arguably a little out of scope,

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