[Rd] Wait for user input with readline()

From: Nathan Miller <natemiller77_at_gmail.com>
Date: Mon, 22 Nov 2010 13:11:34 -0800


Hello,

I am trying write a script that includes a prompt for user input using readlines() and was told that folks at R-devel might be able to help.

 I am running into the problem that when I run readlines() as a single line the prompt works perfectly, but when I try to run a block of code which includes the readline function, the script doesn't wait for the user input. I have seen this question posted before when I did a search, but I didn't find an suitable answer. Is there a means of ensuring that the script does not proceed until a value has been entered to readline(). Can I put readline in a function that will wait for input?

Are there other options for getting user input that allow require that the script wait for user input?

In the code I want the user to input the value for O2sat using O2sat=as.numeric(readline("What is the O2 saturation in umole/L?"))

The problem is that when I run this entire block of code rather than running individual functions, the program doesn't wait for the user input and just continues to the next line of code. Does anyone have a work around for this type of problem?

Thanks for your help,

Nate

#################


O2sat=as.numeric(readline("What is the O2 saturation in umole/L?"))

r=function(x) {

        deltaO2=meanblank-q[2]
        umoleO2=(deltaO2/100)*O2sat

    }

umoleO2perL=r(minO2mean)
umolesO2consumed=umoleO2perL*Vial_vol
names(umoleO2consumed)="umoleO2consumed" O2consumed=data.frame(filenames,umoleO2consumed) O2consumed

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 22 Nov 2010 - 21:52:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 07 Dec 2010 - 09:20:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive