问题描述
我想通过一个R脚本。我在查找如何执行此操作时看到了debug命令,但这似乎只适用于函数。这个脚本没有任何功能。浏览器命令看起来很有前途,所以我把browser()作为我的脚本的第一行,当我运行它似乎做任何事情。
如何让脚本暂停在第一行,以便我可以通过它?
我偏偏RStudio,所以我推荐以下内容:
- 下载
- 打开您的R脚本
- 将光标放在第一行
- 点击ctrl + enter(PC / Linux)或命令+ return(Mac)
- 重复!
RStudio的一个不错的功能是RStudio服务器可以在无头服务器上运行良好。然后,您可以通过本地计算机上的Web浏览器中的http连接到服务器。在EC2实例上运行R时,我使用此配置。 RStudio保持状态,所以如果我在我的火车上丢失互联网访问,当我得到信号后,RStudio正好在我离开的地方,我的远程机器不知道我断开连接并重新连接。请注意,RStudio服务器目前仅支持FC / CentOS和Debian / Ubuntu。虽然它可以在* nix的其他变体下进行编译。
I want to step through an R script. I saw the "debug" command while searching for how to do this but that seems to only apply to functions. This script doesn't have any functions.
The "browser" command looked promising so I put "browser()" as the first line of my script but it didn't seem to do anything when I ran it.
How do I get the script to pause on the first line so I can step through it?
I'm partial to RStudio, so I recommend the following:
- Download RStudio
- Open your R Script
- put your cursor on the first line
- click ctrl + enter (PC/Linux) or command + return (Mac)
- repeat!
A nice feature of RStudio is that RStudio server can run great on a headless server. You then connect to the server via http in a web browser on your local machine. I use this configuration when running R on EC2 instances. RStudio maintains state so if I lose internet access on my train ride, when I get signal back RStudio picks up exactly where I left off and my remote machine has no idea that I disconnected and reconnected. Note that RStudio server is currently only supported on FC/CentOS and Debian/Ubuntu. Although it may compile under other variants of *nix.
这篇关于如何从开始步入R脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!