Reputation: 819
I have been reading other questions on this topic (see read.table() and read.csv both Error in Rmd), but I believe I have set my working directory fine and the answers are not adequately answering my question...
Here is my code:
---
title: "WQ"
author: "A"
date: "October 13, 2017"
output:
html_document:
fig_height: 6
fig_width: 12
classoption: landscape
---
```{r}
setwd("C:/Users/K/Box/Projects/DRIP/3. Data/working/R_markdown")
x <- read.csv("Nash_longform_subset.csv",as.is=T)
y <- read.csv("Nash_longform.csv", as.is=T)
```{r}
All files and the R markdown file are in the same folder (set above in the code). The code itself runs perfectly, but will not export through R Markdown...
And I get the error:
x Line 14 Error in file(file, "rt"): cannot open the connection calls:
<Anonymous>... withVisible -> eval -> eval -> read.csv -> read.table -> file
Upvotes: 0
Views: 4788
Reputation: 2216
The problem is that you are missing an slash in your wd so R doesn't find the document, that's what Error in file(file, “rt”) means. More explicitly is that R is looking for the first file in this path:
"C:/Users/K/Box/Projects/DRIP/3. Data/working/R_markdownNash_longform_subset.csv"
change your wd to:
setwd("C:/Users/K/Box/Projects/DRIP/3. Data/working/R_markdown/")
Upvotes: 1