Your call to
data doesn’t work because the
gsynth package doesn’t have a data set called “gsynth”, instead its data set is called “simdata”. But if you’ve loaded the package, any included data sets are already available to you without invoking
data** — in fact, it’s usually undesirable to do so. You can read more about this in the “Good Practice” section of the documentation for
A common problem is that you’ve created an object interactively (or while testing a previous iteration of your code) and it’s lingering in your global environment even though the code in the file you’re knitting doesn’t actually successfully create that object.
In these situations, restarting your R session and clearing your global environment before running your code at the console will reveal the ugly truth — but you may need to pick through your R history to figure out how to capture in your script the steps you took to create those lingering objects.
** To convince yourself this is true, in a fresh R session with an empty global environment, try: