开发者

R x11 on Mac not functioning - or, functioning weirdly

开发者 https://www.devze.com 2023-03-02 04:50 出处:网络
I have a simple R script in a file Test.r: x11() plot(1,1) From the terminal, I type \"Rscript Test.r\" and x11 opens and quickly flashes the 开发者_Go百科plot with a point at (1,1), and then quick

I have a simple R script in a file Test.r:

x11()
plot(1,1)

From the terminal, I type "Rscript Test.r" and x11 opens and quickly flashes the 开发者_Go百科plot with a point at (1,1), and then quickly closes the window, however x11 remains open.

How do I keep the plot open? Why does it leave so quickly?


R will close the device when the process R dies (as it does when the script completes). The better way to do this is:

pdf("file.pdf")
plot(1,1)
dev.off()

then when you run through the Rscript it will save the file there. Otherwise, you'll have to have R stay alive which isn't really how it should be run in a script.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号