Skip to content
Back to formatted view

Raw Message

Message-ID: <CAHmzXO7DP46aQhmW59OSE2=uXp4UCCrjPpYUu1mpvqRyAdfV=w@mail.gmail.com>
Date: 2012-02-07T23:05:22Z
From: Gang Chen
Subject: Setting up infile for R CMD BATCH

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 following at the terminal:

R CMD BATCH answer.R output.Rout

it failed to pick up the answer '1' from the 2nd line in answers.R as
shown inside output.Rout:

> source("myTest.R")
input type (0: quit; 1: type1; 2: type2)?
> 1
[1] 1

What am I missing here?

Thanks in advance,
Gang