Is there a compatibility issue with the latest version of R (3.4.2) and ggplot2? My R Shiny app was working two days ago. The plots stopped working yesterday and I noticed that ggplot2 was moved to `tidyverse/ggplot2' in github. I updated the package,
LoadGithubPackage('ggplot2', 'tidyverse/ggplot2')
but still the plots do not look right anymore.
Mine's still working fine, however when using ggplot I'm doing something like this in the server function for shiny:
output$GOOG.forecast <- renderPlot({
b <- GOOG.forecast
plot(b)
})
Just remember when you're doing plot outputs in shiny you have to define the data within the output function (I know it's kinda weird) but this has always worked for me. Otherwise consider using dygraphs if it's appropriate.
Hope this helps!
I would try reverting to CRAN's version of ggplot2 with
install.packages("ggplot2")
and see if that fixes it
Related
When I generate any ggplot2 plot using R magic in Jupyter Notebook, all text in the plot is rendered as little empty boxes.
My environment is running the notebook via Jupyter Hub on Ubuntu server. R magic is working great in general, with the goal of re-using some existing R code I have to output a Word Cloud via wordcloud package. However, when I generate any plot using ggplot2 any text is missing and all I see are small empty boxes.
library(ggplot2)
ggplot(mtcars, aes(x = drat, y = mpg)) +
geom_point()
see image here
The plot should show text on the axis labels but no text is displayed, just empty boxes.
Generating the same plot when running R from ssh terminal and saving it to disk (it's on a headless server) looks fine. Generating plot via pandas data frame in a different cell looks fine. So it seems related to rpy2? I'm stumped.
[EDIT]: in fact I see the same behavior using R kernel on this server, so it seems to not be specific to rpy2 / R magic.
I was able to solve this by installing all the needed packages via R install.packages() rather than conda. Next time I think I will avoid using conda for R packages altogether; this isn't the first time it has caused issues.
I am facing a strange issue. Have written a code with ggplot2 which is getting executed perfectly in Rstudio and the plots are getting displayed.But when i am trying to publish into html using knitr the output plots are not getting displayed. I have tried print() to display and it is still not working.
I have tried reinstalling Rstudio as well.
{r,include=TRUE,echo=TRUE,eval=FALSE}
meandaytype<-
aggregate(analysis1$steps,by=list(analysis1$Daytype,analysis1$interval),mean)
names(meandaytype)[1]<-"Daytype"
names(meandaytype)[2]<-"Interval"
names(meandaytype)[3]<-"steps"
p<-ggplot(meandaytype,aes(x=Interval,y= steps,color=Daytype)) +
geom_line()+facet_grid(Daytype~.)+labs(title="Mean steps per inteval and day
type",x="Interval",y="MeanSteps")
print(p)
Any help would be appreciated. I am using version 1.1.447
I ran into a very weird problem: my R code for generating a plot only works if I type it into the console but not when I ran it inside the script (with Ctrl+Enter command)... It's the same problem with all plots (regular plots or ggplots). Also I tried it on two different computers and the same thing happened. Anyone have any idea why this is happening?
One possible reason: I installed the newest version of Rstudio on both computers so it might be an issue with the version. The exact same code worked before on an older version of rstudio...Could this be it? If so, how can I fix it?
I think I figured out what the problem was: the setting in the new version of Rstudio has a default option of outputting the plots inside the Rmarkdown script (at the very end of the script). And that's why I wasn't seeing them. You could change the setting such that it outputs in the console.
Try dev.off() to reset the graphics device.
This helps with a lot of weird graphics behaviour.
Probably too late for the original poster... However, I just ran into the same problem after installing an R update. The way I fixed it was to go to preferences, R markdown, and turn off "show inline output". For me, it was just coming out at the bottom of the chunk instead of in the plot window like I wanted. Hope that helps someone!
I just ran into this problem. I mistakenly put my plot() command inside the r markdown setup chunk. I moved it to its own code chunk and it ran as expected.
Whenever I plot any plot in RStudio, I get a new device window that pops up. This was not always the case. I must have changed some settings. How do I change the settings back to have plots go to the RStudio plot window?
I have explored the dev.off() and other dev functions without success. For example:
# Clear workspace
rm(list=ls())
# create data
set.seed(1)
x <- rnorm(100, 0, 1)
y <- rnorm(100, 3, 1)
plot(x,y)
produces the popped up window in the screenshotted image:
I want the device to stay in the RStudio plot window in the lower righthand corner. Does anyone have any help? I saw a similar question here that claims that an update will fix the issue. I updated within the last week. When I use sessionInfo() I am running R version 3.3.2, what I believe to be the latest version of R.
I know that this has been answered but the problem can arise in multiple ways. My issue had been much simpler. The plots were not showing up in the Rstudio plot pane simply because the default null GD was turned off via dev.off(). I'm running Rstudio Version 1.1.442 with R Version R-3.4.4
I ran dev.off() a few times until all windows including hidden ones were closed and I received the following response in the console window.
null device
1
I then ran this and the plot appeared in the RStudio plot pane
dev.new()
plot(mtcars$mpg~mtcars$disp)
For others who like me may still encounter this issue:
This is probably caused by an R update to 3.3.2 and is fixed by installing a newer version of RStudio. In my case 1.0.136 did the trick.
I solved this problem by updating RStudio (Help--> check for updates). The new version of RStudio I updated to is Version 1.1.383 and this problem was fixed. Currently I have version 3.4.3 for R.
Go to R studio menu bar and Tools->Global options->R Mark down
In that phase select "window" from that list in the "show output preview in:" then apply
When I run my code all my graphs (both ggplot2 and plot) are displayed in an external "Quartz 2 [*]" graphical viewer.
I would like them to be displayed in the R studio GUI plot area to I can better save and view my files, along with the previous versions.
Is there anyway to stop this?
I recently updated my version of R, along with the X11 and xQuartz on my mac (also up to date), and I am guessing these updates are behind it.
I have seen many forums explaining how to get rstudio to export to an external viewer (e.g. "quartz()"), but not the other way.
I have looked, but these threads have not helped:
ggplot plots in scripts do not display in Rstudio
plot panel does not produce plots Rstudio
dev.off() even when hidden hide <- dev.off() is not working either.
Any help would be great,
Thanks.
If you upgrade R without upgrading RStudio, the graphics engine may not be compatible. To fix the "Quartz 2" popout, upgrade RStudio to a newer version that supports the graphics engine in the version of R you have installed.
I had the same problem, and noticed the following output to the console:
Warning message:
R graphics engine version 15 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
Looks like I forgot to reinstall Rstudio as well.. That sorted my problem.