如何从开始步入R脚本? [英] How to step through an R script from the begining?

查看:218
本文介绍了如何从开始步入R脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过一个R脚本。我在查找如何执行此操作时看到了debug命令,但这似乎只适用于函数。这个脚本没有任何功能。



浏览器命令看起来很有前途,所以我把browser()作为我的脚本的第一行,当我运行它似乎做任何事情。



如何让脚本暂停在第一行,以便我可以通过它?

解决方案

我偏偏RStudio,所以我推荐以下内容:


  1. 下载 RStudio

  2. 打开您的R脚本

  3. 将光标放在第一行

  4. 点击ctrl + enter(PC / Linux)或命令+ return(Mac)

  5. 重复!

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:

  1. Download RStudio
  2. Open your R Script
  3. put your cursor on the first line
  4. click ctrl + enter (PC/Linux) or command + return (Mac)
  5. 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脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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