如何获取R中的脚本路径? [英] How to get the script path in R?
本文介绍了如何获取R中的脚本路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
Rscript:确定执行脚本的路径
始终我运行一个R脚本,将我的文档
作为工作目录。
Always I run an R script, it take My Documents
as working directory.
当我运行脚本,我想获取脚本路径并将工作目录更改为它。我可以这样做?
When I run the script, I want to get the script path and change the working directory to it. How I can do this?
我希望这可以使用 source()
函数在同一个文件夹中运行脚本
I want this to run the scripts in same folder with the source()
function.
推荐答案
如果您通过 source
运行脚本,然后尝试 source(file,chdir = TRUE)
。
if you run script by source
, then try source(file, chdir = TRUE)
.
这篇关于如何获取R中的脚本路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文