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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 04 Oct 2005 - 00:25:56 EST

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@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Oct 04 00:36:55 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:34 EST