I want to knit my RMarkdown script to an exportable HTML, PDF, or Word doc. I would like to have the option to do all 3.
My script runs just find in .Rmd files in the source view and preview view, including with output. However, when I try to Knit, I get the same error message for HTML, PDF and Word that my dataset "object is not found".
My Rmarkdown is saved in the same working directory as my data file of choice. My data file is present in my working environment (and again - is recognized when run without Rmarkdown and with the .Rmd file).
I tried using clearing cache and also using eval = FALSE with no success.
Here is the error
Error in eval(expr, envir, enclos) : object 'DataName' not found
Calls: <Anonymous> ... withVisible -> eval_with_user_handler -> eval ->
Execution halted
it would help if you would provide a stripped down version of your script and Rmd file.
Replace your data-file with a simple text-file.
Then you can exactly show us what went okay and what went wrong.
When you knit an Rmd document the code gets executed in a clean environment other than the one you are currently working on so the data frame doesn't exist there, you need to include the necessary code to import the data frame into memory in your Rmd document itself.
Is the same code you used to import the data frame into your current working environment in the first place, you just have to include it in your Rmd document.
For example, supposing your data comes from a csv file you might have used something like this:
I already gave a generic example, if that doesn't work for you, then you would need to explain your specific problem, preferably providing a REPRoducible EXample (reprex) illustrating your issue.