I am getting the below error when trying to "knit HTML" in RStudio.
|................................ | 50% ordinary text without R code |.................................................................| 100% processing file: Preview-b0c112a265.Rmd label: unnamed-chunk-1 Quitting from lines 16-26 (Preview-b0c112a265.Rmd) Error in file(file, "rt") : cannot open the connection Calls: <Anonymous> ... withVisible -> eval -> eval -> read.csv -> read.table -> file Execution halted
I am using RStudio on a 64-bit win8 machine.
If a chunk works in R but not when you knit, it is almost always because you've changed a variable in your global working environment not using code in a chunk. Try restarting your R session and running each chunk sequentially to make sure all your variable values are up to date.
To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.
No Knit HTML button This means that RStudio doesn't understand your document is supposed to be an RMarkdown document, often because your file extension is . txt . To fix this, go to the Files tab (lower right corner, same pane as Plots and Help) and select the checkbox next to your document's name.
Rendering Output If you are using RStudio, then the “Knit” button (Ctrl+Shift+K) will render the document and display a preview of it.
When you run "Knit HTML", the code is trying to find the file you're reading in the same directory where .Rmd
is located because knitr
sets the working directory to that path. As far as I see you have two options.
.Rmd
file in /
and data in /data
, relative path should be, e.g., read.table("./data/myfile.csv"...)
. .
means "here" (wherever the getwd()
is), two dots climb the directory structure up while specifying directories climbs the structure down.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With