5

I'm doing a presentation in slidfy, using the deckjs framework. Everything was ok, but suddenly this chunk of code:

ggplot(cars, aes(x = speed, y = dist)) +  geom_point(color = 'red') + stat_smooth(method = "lm", formula = y ~ x, size = 0.5, se = F)

stopped working and shows this error instead:

## Error: ScalesList was built with an incompatible version of ggproto.
## Please reinstall the package that provides this extension.

The code works perfectly when executed from source or console... But it doesn't work anymore from the R markdown. The function that fails is the stat_smooth(). The rest visualizes ok if executed without the smooth.

Here and here a similar error is reported, and the solution offered is to reinstall ggplot and the packages from github, but I'm not sure which packages should I install, and, besides, the code only fails from Rmarkdown, and not when executed from console or source.

Thanks

Mike Wise
  • 22,131
  • 8
  • 81
  • 104
Pablo
  • 613
  • 7
  • 11
  • 1
    Cleanly start R (in vanilla mode if necessary). Run your existing code (that generates the errors). run `sessionInfo()`. See list of pkgs. Reinstall/upgrade those packages. Try again. NOTE that you should install ggplot2 first before any pkgs that include ggplot2 geoms/scales/etc. – hrbrmstr Dec 24 '16 at 17:13
  • That's what I did... The problem is that the code works! But from console or source. Not from the R markdown. That's the problem. – Pablo Dec 24 '16 at 17:17
  • 2
    how are you knitting the rmd? the knit cmd in RStudio or via function call? – hrbrmstr Dec 24 '16 at 17:44
  • I'm knitting it in RStudio. What puzzles me is that it has been working correctly till today. I've installed some packages lately, but none (or at least, not as far as I know) related to ggplot. – Pablo Dec 24 '16 at 17:51
  • 2
    How does order of package loading differ between knit and "script" document? – Roman Luštrik Dec 24 '16 at 18:27
  • Roman, how can I figure that out? Thanks for your help. – Pablo Dec 24 '16 at 18:37
  • 1
    you could `knitr::purl()` your document, and run the R source code it produces to see where it chokes. – baptiste Dec 24 '16 at 19:18
  • 1
    Print out the results of `.libPaths()` in each environment. I'm guessing they will be different and that the error message is telling you htere is an outdated version on one of the library directories. – IRTFM Dec 24 '16 at 23:24
  • @42- I get the same output in both cases: "/Library/Frameworks/R.framework/Versions/3.3/Resources/library" – Pablo Dec 25 '16 at 09:38

4 Answers4

4

I had a similar problem in RMarkdown after updating ggplot2. I was loading a workspace with plots created with the older version of ggplot2. The solution was to recreate that workspace with the updated version, and now RMarkdown works.

  • This was the situation for me. I had to re-run all of my existing plots, then re-save my environment and then the Markdown compilation worked again. – dmt Mar 01 '17 at 17:01
0

This is very strange; now things are back to normal.

I did what @baptiste suggested, and the R source code just worked ok. After that, I knitted the Rmarkdown again and the error had disappeared!

Pablo
  • 613
  • 7
  • 11
0

in Feb 2017 the same error was resolved by re-installing all the packages (RStudio - Tools - Check for package updates)

userJT
  • 11,486
  • 20
  • 77
  • 88
0

I had similar problem with geom_tufteboxplot . I first updated ggplot2 & ggthemes package, then detached all ggplot related packages and reloaded them. It worked for me.

raja
  • 51
  • 4