0
我想有我腳本的工作目錄設置爲我的Dropbox文件夾,開始時一個簡單的代碼,無論哪臺機器的我在我的代碼運行於:始終將工作目錄設置的Dropbox文件夾的任何機器
setdir <- function(){
wandir <- paste(path.expand("~"), "/Dropbox/_R", sep = "")
curdir <- getwd()
if(curdir!=wandir){
setwd(wandir)
}
}
setdir()
path.expand("~")
的技巧適用於Linux機器,但它不在Windows機器上,因爲它導致C:/Users/username/Documents
而不是C:/Users/username/
。有一個功能可以在全球範圍內工作嗎?