Make R (statistics package) wait for keyboard prompt when run within a bash script

前端 未结 5 1025
别跟我提以往
别跟我提以往 2021-02-15 13:14

I am using R to generate a series of plots within a loop, with the user hitting the enter key to indicate they have seen the plot and it is time to move on. These are interacti

5条回答
  •  轮回少年
    2021-02-15 13:43

    It's a late answer but my goal was similar: Rscript execution should bring up an rgl window with a plot and nothing else, and it should remain there till the window is closed, i.e. the rgl window should not terminate.

    To achieve this, I simply placed this at the end of the R script, and the rgl plot will remain there for manipulation until you quit the window, consuming little CPU time:

    play3d(function(time) {Sys.sleep(0.01); list()} )
    

    For regular 2D R plots, locator() works similarly, or locator(1) if one click should close the plot window.

提交回复
热议问题