r - "Set working directory to source file location"的命令

标签 r rstudio working-directory

RStudio 有一个有用的功能:

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

有没有办法在不使用下拉菜单的情况下做到这一点?

更新:

也许更好的提问方式是:

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

我也找到了这个线程,但解决方案对我不起作用。甚至不是哈德利的!

Rscript: Determine path of the executing script

最佳答案

您可以使用 :

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

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

关于r - "Set working directory to source file location"的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26519172/

相关文章:

r - sapply 的并行版本

r - 在 Rnw 中使用 ggvis 和 knitr

r - 使用带有绘图的 RStudio/knitr 编译 PDF 时出错

java - Ant Mac OS X Appbundler 当前目录路径问题

Java:如何知道 jar 位于 Linux 中的位置

r - 创建 ID 从 1 开始的列,并在另一列中的值在 R 中发生变化时递增

r - 在 data.table : how to get more than 1 column of results? 中分组

css - 使用 css 配置 ioslides 背景

R list.files(my_working_directory) 没有显示文件,但我知道它们在那里。怎么修?

R 聚合和非空计数