I am attempting to construct a simple script, which creates a graph; closes it when a key is pressed. My code:
#!/usr/bin/Rscript
library(tidyverse)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), colour = "blue")
I have tried the answers from the linked question to pause the script after the plot is drawn. However:
- No plot appears, alto the code works fine from the interactive
R
shell. readline()
works only in interactive mode, as per the documentation, andscan()
is line-buffered, instead of reacting to a single keypress
How does this work? My environment is Debian.