Closed gexijin closed 2 months ago
That didn't work. None of the shiny plots show up when running on a Linux server. Linux servers lacks a graphics device. Headless server.
Alternative solution:
`
pdf(NULL) #otherwise, base R plots sometimes do not show.
Ensure all devices are closed when the session ends session$onSessionEnded(function() { while (dev.cur() > 1) { dev.off() } }) `
pdf (NULL) did not workcfor me , still getting" Error! cannot open file 'Rplots.pdf'" on Windows....
Restart RStudio typically resolve this issue. It is caused by too many plots created in session. Please let me know if you have any
Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Jan Zachar @.> Sent: Sunday, May 26, 2024 11:41:05 AM To: gexijin/RTutor @.> Cc: Ge, Xijin @.>; Author @.> Subject: Re: [gexijin/RTutor] Error in pdf(NULL) : too many open devices (Issue #91)
pdf (NULL) did not workcfor me , still getting" Error! cannot open file 'Rplots.pdf'" on Windows....
— Reply to this email directly, view it on GitHubhttps://github.com/gexijin/RTutor/issues/91#issuecomment-2132281020, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AELDI4IK3P5IF33HD23QWPDZEIGCDAVCNFSM6AAAAABH2UXZPOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZSGI4DCMBSGA. You are receiving this because you authored the thread.Message ID: @.***>
I have to say RTutor is very helpfull and promosing tool. Very similar to Julius AI, which concentrated so far primerly upon Python. Good job. :) The only drawback - just after one or two commands (usually after one or two plots) it runs into "Error! cannot open file 'Rplots.pdf'". And this relates to plot generation as well as to any kind of results in general. Restarting R studio does not bring anything at all...
I also quickly ran into the issue: Error! cannot open file 'Rplots.pdf', when using the web version of RTutor today. Here are the steps that caused the error when using the iris dataset.
Prompt 1) Generate histograms of all variables. RTutor Code:
library(ggplot2)
library(gridExtra)
# Generate histograms for each numeric variable
p1 <- ggplot(df, aes(x = Sepal.Length)) +
geom_histogram(binwidth = 0.5, fill = "blue", color = "black") +
ggtitle("Sepal Length")
p2 <- ggplot(df, aes(x = Sepal.Width)) +
geom_histogram(binwidth = 0.5, fill = "green", color = "black") +
ggtitle("Sepal Width")
p3 <- ggplot(df, aes(x = Petal.Length)) +
geom_histogram(binwidth = 0.5, fill = "red", color = "black") +
ggtitle("Petal Length")
p4 <- ggplot(df, aes(x = Petal.Width)) +
geom_histogram(binwidth = 0.5, fill = "purple", color = "black") +
ggtitle("Petal Width")
# Combine the plots into one
grid.arrange(p1, p2, p3, p4, ncol = 2)
Prompt 2) Now generate histograms of all variables with theme_bw(). RTutor Code:
library(gridExtra)
# Generate histograms for each numeric variable with theme_bw()
p1 <- ggplot(df, aes(x = Sepal.Length)) +
geom_histogram(binwidth = 0.5, fill = "blue", color = "black") +
ggtitle("Sepal Length") +
theme_bw()
p2 <- ggplot(df, aes(x = Sepal.Width)) +
geom_histogram(binwidth = 0.5, fill = "green", color = "black") +
ggtitle("Sepal Width") +
theme_bw()
p3 <- ggplot(df, aes(x = Petal.Length)) +
geom_histogram(binwidth = 0.5, fill = "red", color = "black") +
ggtitle("Petal Length") +
theme_bw()
p4 <- ggplot(df, aes(x = Petal.Width)) +
geom_histogram(binwidth = 0.5, fill = "purple", color = "black") +
ggtitle("Petal Width") +
theme_bw()
# Combine the plots into one
grid.arrange(p1, p2, p3, p4, ncol = 2)
Error Thrown:
It appears that something is going on when grid.arrange() or ggplot() is called twice in a row.
A solution to the Error Rplots.pdf was released in RTutor V1.0. Please let us know if the error occurs again.
Removing the pdf(NULL) from server function.
pdf(NULL)