Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R Windows OS choose.dir()文件选择器赢得';无法在工作目录中打开_R_Filechooser_Working Directory - Fatal编程技术网

R Windows OS choose.dir()文件选择器赢得';无法在工作目录中打开

R Windows OS choose.dir()文件选择器赢得';无法在工作目录中打开,r,filechooser,working-directory,R,Filechooser,Working Directory,choose.dir函数参考页中有一个示例: choose.dir(getwd(), "Choose a suitable folder") 这将启动工作目录中的文件夹选择窗口。但是,我只在“我的电脑”上打开文件夹选择窗口。此函数不能按预期工作的原因是什么?您是对的,您不应该使用choose.dir(),因为它是特定于操作系统的。我确实可以重现您报告的问题-我的猜测是,它不允许您在属于“Root”用户的目录中启动(在Windows中可能意味着什么),因为它似乎适用于其他目录,而不是在“Root

choose.dir函数参考页中有一个示例:

choose.dir(getwd(), "Choose a suitable folder")

这将启动工作目录中的文件夹选择窗口。但是,我只在“我的电脑”上打开文件夹选择窗口。此函数不能按预期工作的原因是什么?

您是对的,您不应该使用
choose.dir()
,因为它是特定于操作系统的。我确实可以重现您报告的问题-我的猜测是,它不允许您在属于“Root”用户的目录中启动(在Windows中可能意味着什么),因为它似乎适用于其他目录,而不是在“Root”下:

 getwd()
 # [1] "C:/Users/Root/Documents"
 choose.dir(getwd(), "Choose a suitable folder") # leads to 'Computer'

 setwd("C:/datathon")
 choose.dir(getwd(), "Choose a suitable folder") # select subfolder 'scripts', works OK
 # [1] "C:\\datathon\\scripts"
有两种独立于操作系统的解决方案;第一个是使用
tcltk
包中的以下功能:

 library(tcltk)
 setwd('~')
 getwd()
 # [1] "C:/Users/Root/Documents"
 dir <- tclvalue(tkchooseDirectory())  # opens a dialog window in 'My Documents'

您是对的,您不应该使用
choose.dir()
,因为它是特定于操作系统的。我确实可以重现您报告的问题-我的猜测是,它不允许您在属于“Root”用户的目录中启动(在Windows中可能意味着什么),因为它似乎适用于其他目录,而不是在“Root”下:

 getwd()
 # [1] "C:/Users/Root/Documents"
 choose.dir(getwd(), "Choose a suitable folder") # leads to 'Computer'

 setwd("C:/datathon")
 choose.dir(getwd(), "Choose a suitable folder") # select subfolder 'scripts', works OK
 # [1] "C:\\datathon\\scripts"
有两种独立于操作系统的解决方案;第一个是使用
tcltk
包中的以下功能:

 library(tcltk)
 setwd('~')
 getwd()
 # [1] "C:/Users/Root/Documents"
 dir <- tclvalue(tkchooseDirectory())  # opens a dialog window in 'My Documents'

什么操作系统和R版本?什么是
getwd()
返回的?我应该提到getwd()不返回“我的计算机”,它给出了我的工作目录的路径。我使用的是RStudio 0.99.485,在Windows mingw32上使用的是R版本3.2.0。getwd()位于{utils}包中,我不确定这是否特定于Windows。其他人在使用示例代码时得到的结果是什么?可能。我认为这意味着您不能选择路径在“计算机”外部的文件夹,而不是声明choose.dir()的默认位置必须是Windows上的“计算机”。“choose.dir(getwd())”是否适用于其他人,还是仅对我无效?
choose.dir()
仅在Windows上存在,因此我无法检查。。。您的工作目录是否在
计算机
之外,即在不同的驱动器上(我猜)?'getwd()[1]“C:/Users/bla35s/Documents”和C:是否在'Computer'内部什么操作系统和R版本?什么是
getwd()
返回的?我应该提到getwd()不返回“我的计算机”,它给出了我的工作目录的路径。我使用的是RStudio 0.99.485,在Windows mingw32上使用的是R版本3.2.0。getwd()位于{utils}包中,我不确定这是否特定于Windows。其他人在使用示例代码时得到的结果是什么?可能。我认为这意味着您不能选择路径在“计算机”外部的文件夹,而不是声明choose.dir()的默认位置必须是Windows上的“计算机”。“choose.dir(getwd())”是否适用于其他人,还是仅对我无效?
choose.dir()
仅在Windows上存在,因此我无法检查。。。您的工作目录是否在
计算机
之外,即在不同的驱动器上(我猜)“'getwd()[1]”C:/Users/bla35s/Documents“”,C:在“计算机”内部