[R] repeating a loop

R. Michael Weylandt michael.weylandt at gmail.com
Mon Nov 7 20:03:16 CET 2011


Could you just initialize RepeatPlot = "y" and then wrap your whole
script in while(RepeatPlot == "y") { ## YOUR STUFF ENDING WITH A
POSSIBLE MODIFICATION OF RepeatPlot }?

Michael

On Mon, Nov 7, 2011 at 1:49 PM, Amit Patel <amitrhelp at yahoo.co.uk> wrote:
> Hi
>
> I have implented boxplots in my script to create box plots
>
> BoxplotsCheck <- readline(prompt = "Would you like to create boxplots for any Feature? (y/n):")
>   if (BoxplotsCheck  == "y"){
>     BoxplotsFeature <- readline(prompt = "Which Feature would you like to create a Boxplot for?:")
>     BoxplotsFeature <- as.numeric(BoxplotsFeature)
>     BoxplotsData <- as.numeric(which(PCIList == BoxplotsFeature))
>     BoxplotsData <- TotalIntensityList[BoxplotsData,]
>     BoxplotsHeading <- paste("Tukey boxplot (including outliers) for PCI ", BoxplotsFeature , sep = "")
>     bplot(as.numeric(BoxplotsData), GroupingList, style = "tukey", outlier = TRUE,
>   col="red", main = BoxplotsHeading,
>     xlab = "Groups", ylab = "Normalised Intensity", plot = TRUE)
>     BoxplotsFilename <- paste(BoxplotsFeature, "_Boxplot", sep = "")
>     savePlot(filename = "BoxplotsFilename", type = "jpeg", device = dev.cur(), restoreConsole = TRUE)
>
>
> RepeatPlot <- readline(prompt = "Would you like to create another boxplot for any Feature? (y/n):")
> }
>
>
> If the user inputs "y" for BoxplotsCheck then a boxplot is saved and creatyed based on a user choice.
>
> I want to include the option to do another boxplot if needed (i.e. another user prompt after saveplot returning another y or n for the variable "RepeatPlot "  ) how can i do this. I guess some kind of loop continuing whileRepeatPlot == y
>
> Can anyone help
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>
>



More information about the R-help mailing list