相关文章推荐
伤情的红豆  ·  r - recreate ...·  1 年前    · 
果断的汤圆  ·  r - ggplot: object ...·  1 年前    · 
淡定的墨镜  ·  ggplot2 ...·  1 年前    · 
路过的皮带  ·  vue-quill-editor ...·  1 年前    · 
失落的饼干  ·  Switch ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

This is embarrassing. I've been using the ggplot2 package on a regular basis over the past few months, and now suddenly things seem to go seriously wrong.

Apparently, whenever I try to plot a bar graph I obtain the error:

Error in structure(list(call = match.call(), aesthetics = aesthetics, : object 'DiscreteRange' not found

This is the error that results, e.g., when I try to run a code as simple as the following:

library(ggplot2)
ggplot(diamonds, aes(x=cut)) + geom_bar()

There is no graphics output, the code stops with the above error message.

If I recall correctly this used to work up to a few days ago, so I suspect that there is some error in an (update of) another package that interferes. Of course, I may also be doing a very stupid mistake that I don't see.

I'm using RStudio version 0.99.467; more information concerning the system and the relevant packages is provided below:

> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS
locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
[1] ggplot2_1.0.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.0         lattice_0.20-33     zoo_1.7-11          digest_0.6.8        MASS_7.3-43         grid_3.2.1          plyr_1.8.3          gtable_0.1.2       
[9] magrittr_1.5        scales_0.2.5.9003   stringi_0.5-5       reshape2_1.4.1      proto_0.3-10        blotter_0.9.1666    tools_3.2.1         stringr_1.0.0      
[17] munsell_0.4.2       colorspace_1.2-6    quantstrat_0.9.1669

I tried to restart a fresh R session and even rebooted the computer, to no avail.

Thank you very much for your help!

I'm going to take a guess that the problem is with the scales package, which is at version: 0.2.5.9003. The packages with "four-part" version numbers x.y.z.wwww look like development versions to me. The current CRAN version is 0.2.5:

 a1 <- available.packages()
 a1[a1[,"Package"]=="scales","Version"]  ## 0.2.5

I don't know how you ended up with a development version (devtools::install_github("hadley/scales") would probably do it) but I would install.packages("scales") (or the equivalent through the RStudio GUI) to re-install the CRAN version and see if that resolves the problem.

Alternatively, you could try keeping the development version of scales and moving to the development version of ggplot2 (devtools::install_github("hadley/ggplot2")).

I'm using the development version of ggplot2 (1.0.1.9003) with the development version of scales (0.2.5.9003) and your example works fine.

Chapeau! I'm officially impressed. Thank you so much! Installing scales from CRAN brought my ggplot back to life :-) – RHertel Aug 13, 2015 at 19:06

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.