[R] Loop function/comparison operator problem

jimdare jamesdare26 at gmail.com
Tue Oct 6 01:47:26 CEST 2009


Hi There,

I have created the following function

format<- function(){
repeat {
form<-readline(paste("\nIn what format do you want to save these
plots?\nChoose from: wmf, emf, png, jpg, jpeg, bmp, tif, tiff, ps, eps, or
pdf.\nNote: eps is the suggested format for publication quality plots.\nPlot
format --> "));
	cat("\nI'm sorry, I don't know what that format is.\nPlease try
again\nPress ENTER...");readline()}
	if (form == c("wmf", "emf", "png", "jpg", "jpeg", "bmp", "tif", "tiff",
"ps", "eps", "pdf")) {break}
}

How do I get the program to recognise that the user has entered one of the
formats in the last line?  Even entering "png" insted of png at the prompt
doesn't seem to work.  Will the loop only break if I enter all of the
possible formats?

Thanks in advance,

James 
-- 
View this message in context: http://www.nabble.com/Loop-function-comparison-operator-problem-tp25757203p25757203.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list