How to set the current file location as the default working directory in R programming?

后端 未结 5 1093
执笔经年
执笔经年 2020-12-30 01:11

I want to make the current file location as the working directory.

Using Rstudio (Works!):

# Author  : Bhishan Poudel
# Program :         


        
5条回答
  •  一生所求
    2020-12-30 01:35

    Simply, use rstudio API, extract its directory, and set it as a working directory as shown below:

    setwd(dirname(rstudioapi::getSourceEditorContext()$path))
    

    Verify if you set the directory correctly by the following command:

    getwd()
    

提交回复
热议问题