Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.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路径中向后移动一个目录_R - Fatal编程技术网

在R路径中向后移动一个目录

在R路径中向后移动一个目录,r,R,假设这是我的R脚本所在的工作目录: C:/Users/Indrajeet Patil/Dropbox/Study 1/Data analysis 我知道如何在当前工作目录中创建一个新目录- dir.create(path = paste(getwd(), '/Results', sep = '')) 我正在努力解决的是如何告诉R向后移动一个文件夹并创建一个新目录。因此,在本例中,我想在文件夹Study 1中创建一个新文件夹,并将其命名为Results 在需要将添加到路径开头时返回。如中所示

假设这是我的R脚本所在的工作目录:

C:/Users/Indrajeet Patil/Dropbox/Study 1/Data analysis
我知道如何在当前工作目录中创建一个新目录-

dir.create(path = paste(getwd(), '/Results', sep = '')) 

我正在努力解决的是如何告诉
R
向后移动一个文件夹并创建一个新目录。因此,在本例中,我想在文件夹
Study 1
中创建一个新文件夹,并将其命名为
Results

在需要将
添加到路径开头时返回。
如中所示

dir.create(path = '../Results')

使用
。/
向上移动一个。无需将路径粘贴在一起,新目录通常已经在工作目录中(我相信)。谢谢。如何使用
getwd
函数执行相同操作。也就是说,我希望通过使用
base::getwd
从cwd向后一步获取文件夹的路径
getwd(…)
不起作用。@IndrajeetPatil,
dirname(getwd())
起作用,尽管它不是真的需要。太棒了!!这正是我需要的。