Pop up the graphics window from Rscript, Example 1:
library(tcltk)
x=1:10
y=1:10
windows() #Use X11() or quartz() if on linux or mac.
plot(x,y)
prompt <- "hit spacebar to close plots"
extra <- "some extra comment"
capture <- tk_messageBox(message = prompt, detail = extra)
The above code presents the plot in a popup window and waits for you to press ok on the tk_messageBox dialog.
Pop up the graphics window from Rscript, Example 2:
png("mygraphic.png")
x = 1:10
print(x^2)
plot(x, x^2, 'o')
print("done")
dev.off()
browseURL("mygraphic.png")
The above code saves the png to disk as a file and asks the operating system to open the file in the program designed for that filetype.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…