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

Package qualifier :: treated as function when missing parentheses #236

Open
mlell opened this issue Dec 2, 2020 · 2 comments
Open

Package qualifier :: treated as function when missing parentheses #236

mlell opened this issue Dec 2, 2020 · 2 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@mlell
Copy link

mlell commented Dec 2, 2020

data("mtcars")
mtcars$cyl %>% forcats::as_factor()
##  [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4
## Levels: 4 6 8

mtcars$cyl %>% forcats::as_factor
## Error in .::forcats : unused argument (as_factor)

So ::is treated as the function name when the parentheses are missing.
Is this on purpose or should it be fixed?

My version of magrittr is 2.0.1.

@krlmlr
Copy link
Member

krlmlr commented Dec 5, 2020

I'm seeing the same behavior with magrittr 1.5:

library(magrittr)
mtcars$cyl %>%
  forcats::as_factor
#> Error in .::forcats: unused argument (as_factor)

Created on 2020-12-05 by the reprex package (v0.3.0)

I guess this is one of the reasons to always put parens after the function.

@ggrothendieck
Copy link

ggrothendieck commented Dec 8, 2020

This works with no () after the function.

 mtcars$cyl %>% (forcats::as_factor)

@lionel- lionel- added the bug an unexpected problem or unintended behavior label Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants