Re: [R] Setting up infile for R CMD BATCH

2012-02-09 Thread Gang Chen
Hi Elai, yes, the approach works out pretty well. Thanks a lot for spending time on this and for the great help! Gang On Wed, Feb 8, 2012 at 5:43 PM, ilai ke...@math.montana.edu wrote: I'm going to declare this SOLVED. Yes, if you don't want a separate script for batch, you will need to modify

Re: [R] Setting up infile for R CMD BATCH

2012-02-08 Thread ilai
Gang, Maybe someone here has a different take on things. I'm afraid I have no more insights on this unless you explain exactly what you are trying to achieve, or more importantly why? That may help understand what the problem really is. Do you want to save an interactive session for future runs?

Re: [R] Setting up infile for R CMD BATCH

2012-02-08 Thread Gang Chen
Sorry Elai for the confusions. Let me try to reframe my predicament. The main program myTest.R has been written in interactive mode with many readline() lines embedded. Suppose a user has already run the program once before in interactive mode with all the answers saved in a text file called

Re: [R] Setting up infile for R CMD BATCH

2012-02-08 Thread ilai
I'm going to declare this SOLVED. Yes, if you don't want a separate script for batch, you will need to modify the original script so it either readline or skips it. Here is an example: # Save in file myTest.R # Add this local function to the beginning of your original program

[R] Setting up infile for R CMD BATCH

2012-02-07 Thread Gang Chen
Suppose I create an R program called myTest.R with only one line like the following: type - as.integer(readline(input type (1: type1; 2: type2)? )) Then I'd like to run myTest.R in batch mode by constructing an input file called answers.R with the following: source(myTest.R) 1 When I ran the

Re: [R] Setting up infile for R CMD BATCH

2012-02-07 Thread ilai
You're not missing anything. In your output.Rout: the 1 right after the source('test') is the 1 inputed from answers.R. the [1] 1 is the result of test. Remove the second line from answers.R and see what happens (hint: script ends after the readline prompt). Just out of curiosity, why will you use

Re: [R] Setting up infile for R CMD BATCH

2012-02-07 Thread Gang Chen
Thanks for the help. You're not missing anything. In your output.Rout: the 1 right after the source('test') is the 1 inputed from answers.R. the [1] 1 is the result of test. Remove the second line from answers.R and see what happens (hint: script ends after the readline prompt). That

Re: [R] Setting up infile for R CMD BATCH

2012-02-07 Thread ilai
On Tue, Feb 7, 2012 at 10:50 PM, ilai ke...@math.montana.edu wrote: Ahh, I think I'm getting it now. Well, readlines() is not going to work for you. The help file ?readline clearly states In non-interactive use the result is as if the response was RETURN and the value is ‘’. The implication