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 markdown:
{r echo=FALSE}
dirname(parent.frame(2)$ofile)
script.dir <- dirname(sys.frame(1)$ofile)
setwd(script.dir)
I get error as below:
Error in dirname(parent.frame(2)$ofile) : a character vector argument expected calls :<Anonymous>...