Research Breakthrough Possible @S-Logix pro@slogix.in

Office Address

Social List

How to get User Input in R?

Description

To get the user input using R programming.

Process

   R Function : readLine() or readLines()

Sapmle Code

#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”)
}

Screenshots
get User Input in R