I have mydata.RDATA to be used in R, then I need to load(), which means I need to setwd() curent directory first. I already know how to do it in R.
When I do it in R
If your .Rmd
file is in a subfolder you need to specify the root directory for knitr, even if you've specified a working directory with setwd()
or even an RSudio project.
Fortunately this is as easy as adding the following chunk to the start of your .Rmd
file, right after the YAML:
{r "setup", include=FALSE}
require("knitr")
opts_knit$set(root.dir = "~/path/to/project")
The ~/
is your HOME
directory on Linux (and maybe Mac). If you're on Windows you'll have to tweak this.