如何使用R命令在RStudio中打开脚本文件?

时间:2023-02-06 16:23:08

I have a simple script file called test.R. It's saved in the working directory. When I go to File > Open > test.R, it opens the file in the editor (without executing the code, which is what I want).

我有一个名为test.R的简单脚本文件。它保存在工作目录中。当我去文件>打开>测试。它在编辑器中打开文件(不执行代码,这正是我想要的)。

How do I do this by typing a command in the console window? To be clear, I just want to open (not execute) the file.

如何通过在控制台窗口中输入命令来实现这一点?明确地说,我只想打开(而不是执行)文件。

1 个解决方案

#1


44  

You are looking for file.edit

您正在寻找file.edit

file.edit('test.R')

should open the file in an editor (if you are in RStudio, this should default to RStudio)

应该在编辑器中打开文件(如果您在RStudio中,这应该默认为RStudio)

#1


44  

You are looking for file.edit

您正在寻找file.edit

file.edit('test.R')

should open the file in an editor (if you are in RStudio, this should default to RStudio)

应该在编辑器中打开文件(如果您在RStudio中,这应该默认为RStudio)