[R] Problem building/checking library that requires input from user

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 3 16:25:56 CEST 2005


Either use \dontrun in a \examples{} section of a help page (see Writing 
R Extensions), or something like

num_reps <- if(interactive()) readline("How many reps do you have... ") else 500


On Mon, 3 Oct 2005, Ken Termiso wrote:

> Hi all,
>
> I've got a package i've written that i am trying to check, build, and
> install. This is my 1st time doing this, so apologies in advance... ;)
>
> The package that I've written requires input from the user. It needs to know
> sample sizes and then runs some calcs, (sample sizes are just integers), and
> it gets this info from the user as
>
> num_reps <- readline("How many reps do you have... ")
>
> num_reps <- as.integer(num_reps)
>
> and then loops
>
> for(i in 1:num_reps)
> {
>      #code
> }
>
>
> HOWEVER, I get this error msg when trying to check/build/install:
>
> Error in 1:num_con_biol_reps : NA/NaN argument
>
> Presumably this is because R thinks the variable is never initialized before
> i try to use it as a loop limit...
>
> Anyway around this?? I tried initializing the num_reps variable in the code
> before the readline, but get the same error...

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list