f.lechleitner
f.lechleitner

Reputation: 3812

R - readline-prompt over multiple lines

I'm trying to implement a simple selection using the console. This is the code:

n <- readline(prompt = "1 - selection A\n2 - selection B\nInput: ")

And the whole thing is working, but the input is written at the end of the first line, after 'selection A'. I'd like the user input to be at the end of the prompt (after 'Input: '). Thanks!

enter image description here

Upvotes: 2

Views: 1895

Answers (1)

Gangesh Dubey
Gangesh Dubey

Reputation: 382

As Roman has rightly pointed out, your code should work in RGui. In Rstudio, I would use

cat("1 - selection A\n2 - selection B\n")
n<-readline(prompt ="Input: ")

Upvotes: 4

Related Questions