[R] Load a program at the front end

Gang Chen gangchen6 at gmail.com
Tue Oct 7 19:50:56 CEST 2008


Thanks for the suggestion, Luke!

Your approach would load prog.R whenever invoking R, but that is not
exactly what I want. Basically I can run prog.R through
source("~/someDir/prog.R") inside R. Also since prog.R involves many
lines of readline() and tclvalue() in tcltk package, the program
requires the user responses in the middle of the execution. If
possible, I would like to create an executable  shell script RunProg
with one line or two inside like

R ... ~/someDir/prog.R

If this is feasible, whenever I want to run prog.R, I can simply type
the following at the terminal prompt:

RunProg

and I would still be able to interact with the user. Is this something doable?

Thanks,
Gang



On Tue, Oct 7, 2008 at 12:43 PM, Luke Tierney <luke at stat.uiowa.edu> wrote:
> Something like
>
>    env R_PROFILE=prog.R R
>
> may work for you.  You may need to call .First.sys at the beginning of
> prog.R to get default packages loaded.
>
> luke
>
> On Tue, 7 Oct 2008, Gang Chen wrote:
>
>> Thanks a lot for the suggestion!
>>
>> Unfortunately " R --no-save < prog.R" does not work well with my
>> situation because prog.R
>> contain lines such as readline() and () that require user response in
>> the middle of the
>> execution. I also tried other options such as "R -f prog.R" and "R
>> --interactive < prog.R", and
>> they all failed.
>>
>> Any other suggestions?
>>
>> Thanks,
>> Gang
>>
>>
>> On Mon, Oct 6, 2008 at 10:12 PM, Bernardo Rangel Tura
>> <tura at centroin.com.br> wrote:
>>>
>>> Em Qui, 2008-10-02 às 14:36 -0400, Gang Chen escreveu:
>>>>
>>>> I want to run a R program, prog.R,  interactively. My question is, is
>>>> there a way I can start prog.R on the shell terminal when invoking R,
>>>> instead of using source() inside R?
>>>>
>>>> TIA,
>>>> Gang
>>>
>>> Hi Gang
>>>
>>> I my system just only type:
>>>
>>>  R --no-save <prog.R
>>>
>>> platform       x86_64-unknown-linux-gnu
>>> arch           x86_64
>>> os             linux-gnu
>>> system         x86_64, linux-gnu
>>> status         Patched
>>> major          2
>>> minor          7.2
>>> year           2008
>>> month          09
>>> day            11
>>> svn rev        46532
>>> language       R
>>> version.string R version 2.7.2 Patched (2008-09-11 r46532)
>>>
>>> --
>>> Bernardo Rangel Tura, M.D,MPH,Ph.D
>>> National Institute of Cardiology
>>> Brazil
>>
>> ______________________________________________
>> R-help at 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.
>>
>
> --
> Luke Tierney
> Chair, Statistics and Actuarial Science
> Ralph E. Wareham Professor of Mathematical Sciences
> University of Iowa                  Phone:             319-335-3386
> Department of Statistics and        Fax:               319-335-3017
>   Actuarial Science
> 241 Schaeffer Hall                  email:      luke at stat.uiowa.edu
> Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



More information about the R-help mailing list