Re: [R] User inputs

2010-04-22 Thread chrisli1223

Thank you very much Dieter and Don. This solves my problem. :)
-- 
View this message in context: 
http://r.789695.n4.nabble.com/User-inputs-tp2018251p2023067.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] User inputs

2010-04-21 Thread Don MacQueen

At 4:24 PM -0800 4/20/10, chrisli1223 wrote:

Hi everyone,

I have been searching for answers for the following questions but I don't
have much success. The following questions may actually be quite simple. Any
help would be greatly appreciated.

(1) I have written a script which requires user input. I am using the
readline() command.However, everytime when I run the script, R does not wait
for the user input and proceed to the next line. Is there something like
par(ask=T) to solve this problem?

(2) In my script, I want it to stop running when a certain condition is met.
I have tried using the stop() function, but apparently R only stops reading
that line and start reading the following lines. I have also thought about
quit() but it is not quite what I want. May someone please lead me to the
right function please?


Use  if()

## beginning of script

## various R that always run

if ( condition is met) {
  ## here is where we stop
  cat('My condition is met, I am stopping\n')
} else {
  cat('My condition is not met, I am continuing\n')
  ## put here all the commands that should run when the condition is not met
}



(3) When a minor error happens, I would like to get the user permission by
pressing the return key before the script continues to run. What function
should I be looking at?


Use the
  try()
function to control what happens when an error happens



Many thanks,
Chris
--
View this message in context: 
http://*n4.nabble.com/User-inputs-tp2018251p2018251.html

Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://*stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] User inputs

2010-04-21 Thread Dieter Menne


chrisli1223 wrote:
> 
> (1) I have written a script which requires user input. I am using the
> readline() command.However, everytime when I run the script, R does not
> wait for the user input and proceed to the next line. Is there something
> like par(ask=T) to solve this problem?
> 

Depends on how you run the script. Try to insert
print(interactive())

If the result is FALSE, it does not wait. Have you tried a simple

a = readline()

in your GUI? What happens?


Dieter

-- 
View this message in context: 
http://n4.nabble.com/User-inputs-tp2018251p2018551.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] User inputs

2010-04-20 Thread chrisli1223

Hi everyone,

I have been searching for answers for the following questions but I don't
have much success. The following questions may actually be quite simple. Any
help would be greatly appreciated.

(1) I have written a script which requires user input. I am using the
readline() command.However, everytime when I run the script, R does not wait
for the user input and proceed to the next line. Is there something like
par(ask=T) to solve this problem?

(2) In my script, I want it to stop running when a certain condition is met.
I have tried using the stop() function, but apparently R only stops reading
that line and start reading the following lines. I have also thought about
quit() but it is not quite what I want. May someone please lead me to the
right function please?

(3) When a minor error happens, I would like to get the user permission by
pressing the return key before the script continues to run. What function
should I be looking at?

Many thanks,
Chris
-- 
View this message in context: 
http://n4.nabble.com/User-inputs-tp2018251p2018251.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.