J. Wall
J. Wall

Reputation: 11

error using write_csv within R Markdown dowcument

When inputting write_csv(MyComplicationData,"Data/MyComplicationData.csv") as part of a .Rmd file, I get the following error when trying to knit the document:

Error in open.connection(path, "wb") : cannot open the connection Calls: ... write_delim -> stream_delim -> open.connection Execution halted

When I input the same command from the console, it works without a problem. MyComplicationData is a tibble with 4812 observations of 7 variables.

Upvotes: 1

Views: 1666

Answers (1)

Aurélien.AB
Aurélien.AB

Reputation: 130

You can use the getwd() command that return your working directory if the directory in which you want to save it is inside, otherwise you should give the entire path. It would give something like this :

write_csv(MyComplicationData,paste(getwd(),"/Data/MyComplicationData.csv", sep = "") 

or

paste0(getwd(),"/Data/MyComplicationData.csv")

Upvotes: 1

Related Questions