In the game, the console is cleared with cat("\014") between frames. This only clears the screen in RStudio, though. In the terminal it would need to be system("clear").
Via Henrik:
To detect whether R is running via RStudio or not, one can check Sys.getenv("RSTUDIO") which is set to 1 when running in RStudio.
We can detect this on startup, set a field value and then have if statements to choose between cat("\014") and system("clear") whenever the console needs to clear.
In the game, the console is cleared with
cat("\014")between frames. This only clears the screen in RStudio, though. In the terminal it would need to besystem("clear").Via Henrik:
We can detect this on startup, set a field value and then have
ifstatements to choose betweencat("\014")andsystem("clear")whenever the console needs to clear.