r表示运行脚本图解中 [英] Running R Scripts with Plots

查看:146
本文介绍了r表示运行脚本图解中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的shell脚本(bash)的它运行产生的曲线作为输出A R脚本。一切工作正常,但剧情之后被渲染immedietly - [R退出。有没有一种方法,以保持R会话活着,直到阴谋窗口关闭。

I have a small shell script (bash) which runs a R script which produces a plot as output. Everything works fine but immedietly after the plot is rendered R quits. Is there a way to keep the R session alive until the plot window is closed.

shell脚本。

#!/bin/bash
R --slave --vanilla < myscript.r

将R脚本。

daq = read.table(file('mydata.dat'))
X11()
pairs(daq)
//R Completes this and then exits immediately.

在此先感谢您的帮助!

Thanks in advance for any help!

推荐答案

如果您使用RSCRIPT命令(这是更适合的了),你运行它是这样的:

If you use the Rscript command (which is better suited for this purpose), you run it like this:

#!/usr/bin/Rscript

daq = read.table(file('mydata.dat'))
X11()
pairs(daq)

message("Press Return To Continue")
invisible(readLines("stdin", n=1))

请务必设置上myscript.r执行权限,然后运行这样的:

Make sure to set the execute permission on myscript.r, then run like:

/path/to/myscript.r

或未经认领:

Rscript /path/to/myscript.r

这篇关于r表示运行脚本图解中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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