0

I have this code part of a function :

dataplot <- data.frame(x,y)
  p <- ggplot(dataplot, aes(x=x, y=y))

  print(p)

  # Dataset using for plotting
  ggplot_build(p)

And when I run the code there's no problem but as soon as I compile it into an HTLM file there's a problem I get this error message

Error in data.frame(x,y) : p not found

How could you explain this ?

Dave2e
  • 22,192
  • 18
  • 42
  • 50
Laura
  • 1
  • 2
  • Nope, can't explain it. Perhaps you can turn this into a more *reproducible* question? This includes sample code you've attempted (including listing non-base R packages, and any errors/warnings received), sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and intended output. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Apr 06 '20 at 17:28
  • Please be mindful when selecting tags; even (or especially) with tags that are recommended by the Stack engine. For instance, while I recognize you want to generate HTML, your problem is about R (HTML does not enter the equation until this works without error). Also, there is no compiler here, just rendering (though this might seem like a nuance). Lastly, unless the error is introduced by the RStudio IDE (possible), it is more likely a problem with your code (Rmd or R). Tags that might be good: [tag:r-markdown] or [tag:knitr], though I don't know for certain without your clarification. – r2evans Apr 06 '20 at 17:31
  • As it stands, this is a relatively low-quality question that might receive down-votes as such. Please [edit] your question quickly with more details. Don't mind the down-voters, but the longer you delay, the more likely it is that your question will be closed for some reason (currently there are several valid reasons for closure; I often wait to allow the asker to improve the question before closing, not everybody waits). – r2evans Apr 06 '20 at 17:33

0 Answers0