-1

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)

  • 1
    Welcome to SO! What's your question? – pogibas Sep 15 '18 at 08:43
  • 3
    Possible duplicate of [What does "The following object is masked from 'package:xxx'" mean?](https://stackoverflow.com/questions/39137110/what-does-the-following-object-is-masked-from-packagexxx-mean) – pogibas Sep 15 '18 at 08:44

1 Answers1

1

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.

Artem
  • 3,304
  • 3
  • 18
  • 41