How to Wait for a Keypress in R (Example Code)
In this tutorial, I’ll show how to pause an R script until a key is pressed in R programming.
Example: Using Keypress within Manually Specified Function in R
my_function <- function(input) { # Constructing own function output <- input + 10 readline(prompt = "Press [enter] to return the result of your input + 10.") output } |
my_function <- function(input) { # Constructing own function output <- input + 10 readline(prompt = "Press [enter] to return the result of your input + 10.") output }
my_function(input = 20) # Applying own function to input value |
my_function(input = 20) # Applying own function to input value
“Press [enter] to return the result of your input + 10.”
# [1] 30 |
# [1] 30