“将工作目录设置为源文件位置"的命令 [英] Command for "Set working directory to source file location"

查看:49
本文介绍了“将工作目录设置为源文件位置"的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RStudio 有一个有用的功能:

RStudio has a useful feature:

Session -> Set Working Directory -> To Source File Location

有没有不使用下拉菜单的方法?

Is there a way to do this without using the drop down menus?

更新:

也许更好的提问方式是:

maybe a better way of asking is:

有返回当前r脚本文件路径的命令吗?

is there a command to return the file path of the current r script?

我也找到了这个帖子,但这些解决方案对我不起作用.甚至不是哈德利的!

I also found this thread, but the solutions didn't work for me. Not even Hadley's!

Rscript:确定执行脚本的路径

推荐答案

您可以使用:

source("script.R", chdir = TRUE)

并通过您感兴趣的文件的名称更改script.R".

and change "script.R" by the name of the file you're interested in.

这篇关于“将工作目录设置为源文件位置"的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆