I have a project folder, which is my working directory. Let\'s call it project. Under the project folder are 4 subdirectories: code
,
Try this. It assumes you have the 4 folders you listed inside the working directory project
. It also assumes you have a .csv
file called myData.csv
in data
.
When you knit the file, the plot will be saved in figures
. At the end, the code looks for html
files in code
and moves them to documents
. There's probably a better way to do this.
```{r setup}
library(knitr)
opts_knit$set(root.dir=normalizePath('../'))
opts_chunk$set(fig.path = "../figures/", dev='pdf') # corrected path and added dev
```
```{r import}
dat <- read.csv("data/myData.csv")
```
```{r plot}
# pdf(file="figures/test.pdf") # I do this in setup instead
plot(dat)
# dev.off()
```
```{r move}
files <- list.files("code/")
index <- grep("html", files)
file.rename(file.path("code", files[index]),
file.path("documents", files[index]))
```