Both R and Python have facilities where the coder can write a script which requests a user to input some information. In Python 2.6, the main function for this task is raw_input (in Python 3.0, it’s input()). In R, there are a series of functions that can be used to request an input from the user, including readline(), cat(), and scan(). However, I find the readline() function to be the optimal function for this task. In the following blocks of code, I show how to perform the same task using both R and Python.
## R CODE:
num = 0
while(num < 3 ){
num = num + 1
name <- readline(“Hey dude, what’s your name = “)
if( name == “quit” ) { break }
if( name == “Bieber” ) {
cat( “Welcome “, name )
break } }
## PYTHON CODE:
num = 0
while num < 3:
num = num + 1
name = raw_input(“Hey dude, what’s your name = “)
if name == “Bieber”:
print “Welcome “, name
break
if name == “quit”:
break
R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series,ecdf, trading) and more...

Zero Inflated Models and Generalized Linear Mixed Models with R.
Zuur, Saveliev, Ieno (2012).