Closed IndrajeetPatil closed 3 years ago
Ahm...I can't reproduce the error Indrajee @IndrajeetPatil. I got the following outcome (you'll see I trunked the disp
for its coefficient to squeeze the rest to be seen. But plot is still doable. With a wide guess, maybe some other packages overwrote the dplyr::mutate
function? Free to reopen the issue if the problem still exists.
library(dotwhisker)
mod <- lm(mpg ~ wt + cyl + gear, data = mtcars)
# draw a dot-and-whisker plot
dwplot(mod, style = "distribution")
Thanks for the response.
I can still reproduce this error:
library(dotwhisker)
#> Loading required package: ggplot2
mod <- lm(mpg ~ wt + cyl + gear, data = mtcars)
# draw a dot-and-whisker plot
dwplot(mod, style = "distribution")
#> Error: Problem with `mutate()` column `n`.
#> ℹ `n = 1:n()`.
#> x could not find function "n"
#> ℹ The error occurred in group 1: term = "cyl", model = one.
Created on 2021-07-17 by the reprex package (v2.0.0)
The way to make it work is by explicitly loading dplyr
:
library(dotwhisker)
#> Loading required package: ggplot2
library(dplyr)
mod <- lm(mpg ~ wt + cyl + gear, data = mtcars)
# draw a dot-and-whisker plot
dwplot(mod, style = "distribution")
Created on 2021-07-17 by the reprex package (v2.0.0)
The problem is that you are using dplyr::n()
function somewhere but not using either namespace ::
or importing it in your package namespace. So the user needs to do it.
Ah! Got it! I've updated the namespace in the dev version cc2d53c14b3cb48591059c1ea1a8d4b9203d83c3. I've recorded the bug in the News.md for the next update. Thanks for pointing that out!
One more thing: This produces a cryptic warning:
#> Warning in if (is.na(out)) {: the condition has length > 1 and only the first
#> element will be used
Reproducible example:
library(dotwhisker)
#> Loading required package: ggplot2
# define a regression model
m<- lm(mpg ~ wt * cyl, data = mtcars)
# draw a dot-and-whisker plot
dwplot(m, style = "distribution")
#> Warning in if (is.na(out)) {: the condition has length > 1 and only the first
#> element will be used
Created on 2021-09-13 by the reprex package (v2.0.1)
Created on 2021-04-14 by the reprex package (v2.0.0)
Trace: