Unused argument error with ggplot position_dodge(p

2019-08-04 11:05发布

I am getting error when trying to use the preserve argument to position_dodge() described here in the ggplot documentation.

ggplot(
       mtcars,
       aes(
           factor(cyl),
           fill = factor(vs)
           )
        ) +
 geom_bar(position = position_dodge(preserve = "single"))

Error in position_dodge(preserve = "single") : unused argument (preserve = "single")

I am using R version 3.4.1 and ggplot2 version 2.2.1

Any suggestions? Thanks

标签: r ggplot2
1条回答
Bombasti
2楼-- · 2019-08-04 11:23

It looks like the preserve argument is present in the development version of ggplot2 but for the moment only in the function position_dodge2() and not in the normal position_dodge() function. This link shows how I found that information: https://github.com/tidyverse/ggplot2/search?utf8=%E2%9C%93&q=preserve&type=

It's unclear to me why the online documentation (http://ggplot2.tidyverse.org/reference/index.html) shows preserve as a current, usable feature.

If you really want to use this function you could try installing the development version. I have no idea if that would be a good idea or not!

install.packages("devtools")
library(devtools)
devtools::install_github("tidyverse/ggplot2")
查看更多
登录 后发表回答