I ran a code that generates multiple graphs and saved it at the end.
When opening the graphs file saved in R, all the graphs appears, except the histograms.
Here is an example:
data <- mtcars
residuo_test <- (mtcars$gear - mtcars$carb) / mtcars$carb * 100
hist_ap_19 <- list ()
a <- expression (Error ~ class ~ ("%"))
b<- expression (frequency ~ ("%"))
graf_rede_ij_hist1 <- ggplot (mtcars, aes (residuo_test)) + geom_histogram (aes (y = stat (count) / sum (count) * 100), bins = 30) + continuous_scale (limits = c (-50.50,10), name = a) + scale_y_continuous (name = b) +
theme_classic () +
theme (plot.title = element_text (size = 25, face = "bold"),
axis.title = element_text (size = 25, color = "black"),
axis.text = element_text (size = 25, color = "black"))
hist_ap_19[] <- graf_rede_ij_hist1
saveRDS (hist_ap_19, "D: / Desktop / test")
This is how I plot the histogram, but when I open it in a new R session, I get the error:
test <- readRDS (file.choose ())
FUN error (X [[i]], ...): object 'residuo_test' not found
That's because I no longer have the 'residuo_test' data in the environment.
I've tried to save as a print, but it's a loop, and all graphs are saved as the same histogram. Inserting residual calculation in the geom_histogram does not work either.
How can I plot the histograms and open in a new R session without that error?
Can someone help me, please?