I have a very simple .r file:
library("rgl")
par(ask=TRUE)
x=c(0.44,0.45)
y=c(0.2, 0.3)
z=matrix(c(1,2,3,4),nrow=length(x))
persp3d(x,y,z)
When I open a cmd screen and navigate to my R installation and try
Rscript P:\pathtoscript\example.r
I see the persp3d
graph flash up really quickly and then disappear, even though my .r file contains the par(ask=true)
command.
So my question is, how can I keep it up and play around with it, without it going away before I'm done?
Thanks for your help.
I'm not aware of a more idiomatic way to do this type of thing, but you can just add Sys.sleep(large_number_of_seconds)
to keep the R process alive. For example,
script.R
library("rgl")
x <- c(0.44, 0.45)
y <- c(0.2, 0.3)
z <- matrix(c(1,2,3,4),nrow = length(x))
persp3d(x,y,z)
Sys.sleep(100000)
Also, the ask
argument to par
is only used in interactive sessions, which is why it was not working here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.