How to get User Input in R?

Description

To get the user input using R programming.

R Function : readLine() or readLines()

#How to get User Input

name<-readline(prompt = “Enter Your Name : “)
age<-readline(prompt = “Enter Your Age : “)
val<-18-as.integer(age) if(age>=18)
{
cat(“Hello”,name,”You are eligible for voting :)”)
}else
{
cat(“Oops!!!”,name,”You are not eligible for voting \n You need”,val,”more years for voting”)
}

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit