Getting Current Directory
R is a little more straightforward.
1 |
getwd() |
Python needs to import os .
1 2 |
import os as os os.getcwd() |
Change work Directory
R needs /.
1 |
setwd('C:/Directory') |
Python
1 |
os.chdir(r'''C:\Directory''') |
If you put C:\ the chance is you will encounter a Unicode issue, using r'''...''' will get rid of the issue.
Or you can just assign a directory to a variable.
1 2 3 |
path <- 'C:/Directory' #R path <- 'r'''C:\Directory''' #Python |
Then assign later
1 2 3 |
setwd(path) #R os.chdir(path) #Python |