Package qualifier `::` treated as function when missing parentheses
mlell opened this issue · comments
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.
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.
This works with no () after the function.
mtcars$cyl %>% (forcats::as_factor)