R Markdown Object Not Found

Hi all,

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

Hello @Hal ,

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.

1 Like

Thanks @andresrcs !

Would you have the code to do that?

Thanks @HanOostdijk - I'm not exactly sure of how to replace in that manner. Can you reference a place that explains how to do so?

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:

dataName <- read.csv("path/to/your_file.csv")
1 Like

Would you have the code to do that?. .

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.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.