Ken Termiso
2005-Oct-03 13:41 UTC
[R] Problem building/checking library that requires input from user
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... Thanks very much in advance, Ken
Prof Brian Ripley
2005-Oct-03 14:25 UTC
[R] Problem building/checking library that requires input from user
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
Ken Termiso
2005-Oct-03 15:41 UTC
[R] Problem building/checking library that requires input from user
Thanks, Dr Warnes & Prof Ripley... However, upon following the instructions below, I'm getting syntax errors on the line that has \dontshow...below is my code...I get the same error if i omit the first block and just try \dontrun... \dontshow{ num_reps <- 10 } \dontrun{ num_reps <- readline(""How many reps do you have... ") num_reps <- as.integer(num_reps) } could this have anything to do with it running on OS X 10.3 ?? (long shot...but i'm thoroughly lost).. thanks again, ken>From: "Warnes, Gregory R" <gregory.r.warnes at pfizer.com> >To: "'Ken Termiso'" <jerk_alert at hotmail.com> >Subject: RE: [R] Problem building/checking library that requires input from >user >Date: Mon, 3 Oct 2005 10:11:15 -0400 > > >Try changing the example code to: > >\dontshow{ > num_reps <- 10 >} >\dontrun{ > num_reps <- readline("How many reps do you have... ") > num_reps <- as.integer(num_reps) >} > >-Greg > > > > -----Original Message----- > > From: r-help-bounces at stat.math.ethz.ch > > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Ken Termiso > > Sent: Monday, October 03, 2005 9:41 AM > > To: r-help at stat.math.ethz.ch > > Subject: [R] Problem building/checking library that requires > > input from > > user > > > > > > 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... > > > > > > Thanks very much in advance, > > Ken > > > > ______________________________________________ > > R-help at 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 > > > > >---------------------------------------------------------------------- >LEGAL NOTICE >Unless expressly stated otherwise, this message is confidential and may be >privileged. It is intended for the addressee(s) only. Access to this >E-mail by anyone else is unauthorized. If you are not an addressee, any >disclosure or copying of the contents of this E-mail or any action taken >(or not taken) in reliance on it is unauthorized and may be unlawful. If >you are not an addressee, please inform the sender immediately.
Ken Termiso
2005-Oct-03 16:29 UTC
[R] Problem building/checking library that requires input from user
It was in a plain R file...I did not interpret the word 'example' in your email as I should've... So, i've been able to fix the num_reps variable problem - thanks!!>From: "Warnes, Gregory R" <gregory.r.warnes at pfizer.com> >To: "'Ken Termiso'" <jerk_alert at hotmail.com> >CC: "R-Help (E-mail)" <r-help at stat.math.ethz.ch> >Subject: RE: [R] Problem building/checking library that requires input from >user >Date: Mon, 3 Oct 2005 11:48:28 -0400 > >What file are you putting these into? > >I believe this is the correct syntax for the \example{} section of an .Rd >file. > >If you want to do this in a plain R file, (e.g. package/tests/somename.R), >you can use > >if(interactive) >{ > num_reps <- readline(""How many reps do you have... ") > num_reps <- as.integer(num_reps) >} >else > num_reps <- 10 > >instead. > >-G > > > > -----Original Message----- > > From: Ken Termiso [mailto:jerk_alert at hotmail.com] > > Sent: Monday, October 03, 2005 11:42 AM > > To: Warnes, Gregory R; ripley at stats.ox.ac.uk > > Cc: r-help at stat.math.ethz.ch > > Subject: RE: [R] Problem building/checking library that requires input > > from user > > > > > > Thanks, Dr Warnes & Prof Ripley... > > > > However, upon following the instructions below, I'm getting > > syntax errors on > > the line that has \dontshow...below is my code...I get the > > same error if i > > omit the first block and just try \dontrun... > > > > \dontshow{ > > num_reps <- 10 > > } > > > > \dontrun{ > > num_reps <- readline(""How many reps do you have... ") > > num_reps <- as.integer(num_reps) > > } > > > > > > could this have anything to do with it running on OS X 10.3 ?? (long > > shot...but i'm thoroughly lost).. > > > > thanks again, > > ken > > > > > > >From: "Warnes, Gregory R" <gregory.r.warnes at pfizer.com> > > >To: "'Ken Termiso'" <jerk_alert at hotmail.com> > > >Subject: RE: [R] Problem building/checking library that > > requires input from > > >user > > >Date: Mon, 3 Oct 2005 10:11:15 -0400 > > > > > > > > >Try changing the example code to: > > > > > >\dontshow{ > > > num_reps <- 10 > > >} > > >\dontrun{ > > > num_reps <- readline("How many reps do you have... ") > > > num_reps <- as.integer(num_reps) > > >} > > > > > >-Greg > > > > > > > > > > -----Original Message----- > > > > From: r-help-bounces at stat.math.ethz.ch > > > > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Ken Termiso > > > > Sent: Monday, October 03, 2005 9:41 AM > > > > To: r-help at stat.math.ethz.ch > > > > Subject: [R] Problem building/checking library that requires > > > > input from > > > > user > > > > > > > > > > > > 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... > > > > > > > > > > > > Thanks very much in advance, > > > > Ken > > > > > > > > ______________________________________________ > > > > R-help at 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 > > > > > > > > > > >------------------------------------------------------------- > > --------- > > >LEGAL NOTICE > > >Unless expressly stated otherwise, this message is > > confidential and may be > > >privileged. It is intended for the addressee(s) only. > > Access to this > > >E-mail by anyone else is unauthorized. If you are not an > > addressee, any > > >disclosure or copying of the contents of this E-mail or any > > action taken > > >(or not taken) in reliance on it is unauthorized and may be > > unlawful. If > > >you are not an addressee, please inform the sender immediately. > > > > > > > >
Reasonably Related Threads
- Problem building/checking library that requires input fro m user
- Rounding fractional numbers to nearest fraction
- Any way to add to data frame saved as .rData file?
- R CMD check: Uses the superseded package: ‘doSNOW’
- Isolating string containing only file name from complete path