Gary, You are asked to
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. when posting. You have not provided such code, and until you do I doubt we can help. When I wrap your lines in a dummy function: foo <- function(){ cat("Enter value for lower Linf :\n") L1<-scan(n=1) cat("Enter value for upper Linf :\n") L2<-scan(n=1) cat("Enter Linf interval :\n") int_L<-scan(n=1) cat("Enter value for lower K :\n") K1<-scan(n=1) cat("Enter value for upper K :\n") K2<-scan(n=1) cat("Enter K interval :\n") int_K<-scan(n=1) list(L1,L2,int_L,K1,K2,int_K) } and run it as you claim event <- 1 if (event == 1 ) foo() else bar() it prompts for all input and prints the expected result. > sessionInfo() R version 2.5.0 (2007-04-23) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" "base" > Chuck On Thu, 14 Jun 2007, Nelson, Gary (FWE) wrote: > Dear All., > > I've created R-code for which a user will be asked to choose between 2 > analyses. I've written one function for each type of analysis. Within > each function, the users is prompted to enter information. An example > is: > > cat("Enter value for lower Linf :\n") > L1<-scan(n=1) > cat("Enter value for upper Linf :\n") > L2<-scan(n=1) > cat("Enter Linf interval :\n") > int_L<-scan(n=1) > cat("Enter value for lower K :\n") > K1<-scan(n=1) > cat("Enter value for upper K :\n") > K2<-scan(n=1) > cat("Enter K interval :\n") > int_K<-scan(n=1) > > I thought I could evaluate and run the appropriate function at the end > of the program by: > > if(event==1) explore() else evaluate() > > > If I run the whole program and either explore() or evaluate() is run, > the first four prompted entries are skipped over. The console output > for event==1 is TRUE looks like: > >> if(event==1) explore() else evaluate() > Enter value for lower Linf : > 1: > Read 0 items > Enter value for upper Linf : > 1: > Read 0 items > Enter Linf interval : > 1: > Read 0 items > Enter value for lower K : > 1: > Read 0 items > Enter value for upper K : > 1: > > I then tried another way. I created > > runcase<-ifelse(event==1,"explore","evaluate") > > At the bottom of the program I used: > > eval(call(x=runcase)) > > But I still get the same problem. > > Any suggestions? > > > Thanks for your help > > Gary A. Nelson, Ph.D > Massachusetts Division of Marine Fisheries > 30 Emerson Avenue > Gloucester, MA 01930 > Phone: (978) 282-0308 x114 > Fax: (617) 727-3337 > Email: [EMAIL PROTECTED] > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. > Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.