fct_lump_n uses partial argument matching when it calls rank, which generates a lot of warnings if you have options(warnPartialMatchArgs = TRUE) and repeatedly call the function (e.g. in a grouped operation).
library(forcats)
options(warnPartialMatchArgs = TRUE)
x <- c("a", "a", "a", "b", "b", "c", "d")
fct_lump_n(x, n = 2)
#> Warning in rank(-calcs$count, ties = ties.method): partial argument match of
#> 'ties' to 'ties.method'
#> [1] a a a b b Other Other
#> Levels: a b Other
I think the culprit is here, with the named argument given as ties instead of ties.method.
|
if (n < 0) { |
|
rank <- rank(calcs$count, ties = ties.method) |
|
n <- -n |
|
} else { |
|
rank <- rank(-calcs$count, ties = ties.method) |
|
} |
I haven't tried making the change but happy to PR if this would be welcome. I realise rank is unlikely to change signature but at least for me squelching the warnings would be great
fct_lump_nuses partial argument matching when it callsrank, which generates a lot of warnings if you haveoptions(warnPartialMatchArgs = TRUE)and repeatedly call the function (e.g. in a grouped operation).I think the culprit is here, with the named argument given as
tiesinstead ofties.method.forcats/R/lump.R
Lines 149 to 154 in ab81d1b
I haven't tried making the change but happy to PR if this would be welcome. I realise
rankis unlikely to change signature but at least for me squelching the warnings would be great