The “readline” Function in R
Package: Base R (No specific package)
Purpose: To read a line from the terminal (standard input).
General Class: Input/Output
Required Argument(s):
None
Notable Optional Arguments:
prompt: A character string to be used as the prompt.
Example:
# Example usage
user_input <- readline(prompt = "Enter your name: ")
print(paste("Hello,", user_input))In this example, the readline function is used to read a line of input from the user with a custom prompt. The user’s input is stored in the variable user_input, and the script then prints a greeting using that input.