Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assignment of r-base plot to a value

I've a problem with saving a r-base plot to an object. I want to assign whole plot which in fact consists of two plots merged by layout() function into a variable and then merge this plot with other by ggarrange() function. The recordPlot() function does not work cause I receive an error:

## Warning: Package `gridGraphics` is required to handle base-R plots.
## Substituting empty plot.

## Warning: Package `gridGraphics` is required to handle base-R plots.
## Substituting empty plot.

Here's the plot that I want to save:

layout(matrix(c(1, 2), 2, 1))
  hist(X1209_HCC1806_cv$Absorbance)
  boxplot(X1209_HCC1806_cv$Absorbance, horizontal = TRUE)

How does the gridGraphics package work? And how can I assign my plot to a variable in order to use it in ggarrange()?

like image 415
Mateusz Kołek Avatar asked Sep 16 '25 11:09

Mateusz Kołek


1 Answers

Claus is exactly right. You just need to install gridGraphics with install.packages("gridGraphics"). Your code worked perfectly for me.

like image 135
W. A. Birdthistle Avatar answered Sep 18 '25 06:09

W. A. Birdthistle