Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In R is there some function like raw_input() in python?

Tags:

r

In Python, we can use raw_input(), what can I use in R?

>>> raw_input("let x=3 or 4?")
let x=3 or 4?3
'3'
like image 414
Ff Yy Avatar asked Nov 30 '25 15:11

Ff Yy


2 Answers

Try readline():

> input = readline('Enter anything: ')
Enter anything: test
> input
[1] "test"
> 
like image 127
daedalus Avatar answered Dec 03 '25 07:12

daedalus


Here is a better solution:

input = readline(prompt="Enter anything: ")

This will will work in a interactive session

like image 30
Baga Avatar answered Dec 03 '25 05:12

Baga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!