When i try to execute ggplot2 and cowplot it threw me an error stating:
Attaching package: ‘cowplot’
The following object is masked from ‘package:ggplot2’: ggsave
This is what i executed:
library(ggplot2)
library(cowplot)
When i try to execute ggplot2 and cowplot it threw me an error stating:
Attaching package: ‘cowplot’
The following object is masked from ‘package:ggplot2’: ggsave
This is what i executed:
library(ggplot2)
library(cowplot)
cowplot
package is masking ggplot2::ggsave
to avoid confusion and throwing error of unrecognized object format when you try to to save cowplot
object into e.g. pdf-file.
Please see example below:
library(ggplot2)
library(cowplot)
# make a plot
p <- qplot(1:10, 1:10)
# draw into the top-right corner of a larger plot area
p1 <- ggdraw() + draw_plot(p, .6, .6, .4, .4)
ggsave("check.pdf", p1)
# Saving 7.17 x 5.6 in image
# everything is OK
ggplot2::ggsave("check1,pdf", p1)
# Error: Unknown graphics device ''
In case facing problems using ggsave
by default called of cowplot
package you can call it as ggplot2::ggsave
. For details please see What does "The following object is masked from 'package:xxx'" mean? in accordance to PoGibas's comment.