How can I get R to plot something in Unix terminal

人走茶凉 提交于 2020-02-04 04:49:43

问题


I'm running R from Unix and would like to see all output without any pop-ups. So, for example, if in unix I run

R -f test.r

Where test.r is

value = pnorm(rnorm(10000))
hist(value,breaks=10)

I would like the output to include a histogram drawn in the terminal. Is this possible? I'm assuming I need some kind of Unix plotting package.


回答1:


There is txtplot package. Here is an example from the manual on how to output a histogram:

## text based barchart
x <- factor(c("orange", "orange", "red", "green", "green", "red", "yellow", "purple", "purple", orange"))
txtbarchart(x)

If you need more complex plots I would recommend you take a look at gnuplot and Rgnuplot package that allows to call it from R. gnuplot has "dumb" terminal type which outputs ascii graphics.



来源:https://stackoverflow.com/questions/17748656/how-can-i-get-r-to-plot-something-in-unix-terminal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!