[R] Loop function/comparison operator problem

jim holtman jholtman at gmail.com
Tue Oct 6 01:51:35 CEST 2009


use %in% instead of '=='

On Mon, Oct 5, 2009 at 7:47 PM, jimdare <jamesdare26 at gmail.com> wrote:
>
> 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.
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list