0

I am trying to compile a pdf report of my R code. I imported the dataset using the menu options but am now having trouble compiling it because R cannot find the .csv files I used. I have triple checked and the working directory is correct.

I get this error:

Error in eval(expr, envir, enclos) : object 'filename' not found
Calls: <Anonymous>...withVisible...-> eval with Userhandlers -> eval -> eval
Execution Halted

Would appreciate any help. Thanks!

Tried getwd() and setwd() but that doesn't seem to be the issue. Double checked file names and location.

JP1012
  • 1
  • 2
    Are you using an rmarkdown document? Note that those documents must be self contained because they are run in separate R sessions. Nothing in your global environment is available to the document when you compile it. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with the least amount of code to trigger the same error. Make sure `filename` is defined in the document itself. – MrFlick Dec 12 '22 at 20:21

1 Answers1

0

Are you trying to compile an RMarkdown file to pdf? If so, you can specify the working directory in the beginning like this:

knitr::opts_knit$set(root.dir = '/tmp')

At any rate, it should also work if you use the full path name as filename.