[R] For loop isn't working correctly

jim holtman jholtman at gmail.com
Fri Oct 9 18:21:16 CEST 2009


It plots on my system just fine.  You might want to check what
directory (getwd()) that you are plotting in.

On Fri, Oct 9, 2009 at 12:17 PM, Anne Buunk <ann3buunk at hotmail.com> wrote:
>
> Hi. With your help, I've fixed the errors in my for loops.
>
> But now, the for loop isn't working correctly. There should be a plot,
>
> but there's no plot when I run the for loop..
>
>
>
> This is the code:
>
>
>
> letters = c("A","B","C","D","E","F","G","H","I","J")
> numbers = 1:3
>
> for(i in 1:6){                       #6 letters
>                for (j in 1:3) {                   #3 numbers
>                    for (k in -1:1) {             #answer -1,right or +1
>                          fn = paste (i,j,k,".bmp",sep="")
>                          bmp(file = fn)
>                          plot(x = 10, y = 10, ylim=c(0,1), xlim=c(0,1), axes=FALSE, ylab="", xlab="")
>                          text(0.5,0.5, labels = paste(letters[i], "+", numbers[j],"=", letters [i+j+k]))
>                          dev.off()
>                                     }
>                               }
>                           }
>
>
> Can somebody see why this isn't running correctly?
>
>
>
> Thanks for the help untill now! Greetings
>
> _________________________________________________________________
>
>
>        [[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.
>



-- 
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