ggsave(): Error in UseMethod("grid.draw") : no applicable method for 'grid.draw' applied to an object of class "character" : <p>I am trying to save a plot with <code>ggsave()</code>.  I enter the following:</p>

<pre><code>library(ggplot2)

Test = data.frame("X" = seq(1, 10, 1), "Y" = 2*seq(1, 10, 1))

P = ggplot(
    Test, aes(x=X, y=Y))+
    geom_line()

ggsave(P, "test.pdf", device = "pdf")
</code></pre>

<p>But get the error:</p>

<pre><code>Saving 7 x 7 in image
Error in UseMethod("grid.draw") : 
  no applicable method for 'grid.draw' applied to an object of class "character"
</code></pre>
