title: ggplot error: cannot coerce class "c("gg","ggplot")" to a data.frame
body: <p>I am trying to run a pretty simple line of code in order to create a ggplot for homework. I am very new to R, so I suspect this is a simple problem but I'm just treading water at this point. My professor actually wrote this code and it has worked for other students I have spoken to. However, I am getting an error, which is pretty confusing.</p>
  
  <p>Part of the problem may be that I previously attempted to coerce ggplot into a data frame (because I did not realise exactly what ggplot was for a while) and named that gg.</p>
  
  <p>This line of code has been crashing since I began the assignment
  Note: This was code that was provided by my professor and works for others</p>
  
  <pre><code>ggplot(filter(gapminder, gapminder$year==1987, group=1)) + geom_point(aes(gdpPercap, lifeExp, color=continent, size=pop)) + xlab("GDP per capita") + ylab("Life expectancy at birth")
  </code></pre>
  
  <p>I attempted to coerce ggplot to a data frame using:</p>
  
  <pre><code>gg = as.data.frame(ggplot)
  </code></pre>
  
  <p>Obviously this didn't work or help, but after deleting this code from the file it may still be affecting the former line of code??</p>
  
  <p>I expected a plot of some kind at least, but instead I get the following error:</p>
  
  <blockquote>
    <p>Error in as.data.frame.default(x[[i]], optional = TRUE,
    stringsAsFactors = stringsAsFactors) :    cannot coerce class "c("gg",
    "ggplot")" to a data.frame</p>
  </blockquote>
  
  <p>Any help would be appreciated!</p>