[R] Problems with code containing a for loop

2009-10-09 Thread Antje##

The following code isn't working and we can't figure out why..

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, text = paste(letters[i], +,
numbers[j],=, letters [i+j+k]) 
  dev.off()
 }
   }
   }

We get the following errors: 
Error: unexpected symbol in:
  text(0.5,0.5, text = paste(letters[i], +,
numbers[j],=, letters [i+j+k]) 
  dev.off
  }
Error: unexpected '}' in  }
}
Error: unexpected '}' in}
}
Error: unexpected '}' in}
-- 
View this message in context: 
http://www.nabble.com/Problems-with-code-containing-a-for-loop-tp25823173p25823173.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Problems with code containing a for loop

2009-10-09 Thread Erik Iverson
Because you missed your closing parens in the text function call. The closing 
parens is closing the paste function, you need one more.  I don't know what 
you're trying to do here, but I am guessing there's a faster way?  

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Antje##
 Sent: Friday, October 09, 2009 10:37 AM
 To: r-help@r-project.org
 Subject: [R] Problems with code containing a for loop
 
 
 The following code isn't working and we can't figure out why..
 
 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, text = paste(letters[i], +,
 numbers[j],=, letters [i+j+k])
   dev.off()
  }
}
}
 
 We get the following errors:
 Error: unexpected symbol in:
   text(0.5,0.5, text = paste(letters[i], +,
 numbers[j],=, letters [i+j+k])
   dev.off
   }
 Error: unexpected '}' in  }
 }
 Error: unexpected '}' in}
 }
 Error: unexpected '}' in}
 --
 View this message in context: http://www.nabble.com/Problems-with-code-
 containing-a-for-loop-tp25823173p25823173.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@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.

__
R-help@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.


Re: [R] Problems with code containing a for loop

2009-10-09 Thread xavier . chardon
A parenthesis is missing. You can figure that out easily watching the first 
error.

text(0.5,0.5, text = paste(letters[i], +, numbers[j],=, letters [i+j+k]))

Xavier


- Mail Original -
De: Antje## ann3bu...@hotmail.com
À: r-help@r-project.org
Envoyé: Vendredi 9 Octobre 2009 17h36:34 GMT +01:00 Amsterdam / Berlin / Berne 
/ Rome / Stockholm / Vienne
Objet: [R]  Problems with code containing a for loop


The following code isn't working and we can't figure out why..

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, text = paste(letters[i], +,
numbers[j],=, letters [i+j+k]) 
  dev.off()
 }
   }
   }

We get the following errors: 
Error: unexpected symbol in:
  text(0.5,0.5, text = paste(letters[i], +,
numbers[j],=, letters [i+j+k]) 
  dev.off
  }
Error: unexpected '}' in  }
}
Error: unexpected '}' in}
}
Error: unexpected '}' in}
-- 
View this message in context: 
http://www.nabble.com/Problems-with-code-containing-a-for-loop-tp25823173p25823173.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.

__
R-help@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.


[R] Problems with code

2009-10-09 Thread Anne Buunk

The following code isn't working and we can't figure out why.. 

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, text = paste(letters[i], +, 
numbers[j],=, letters [i+j+k]) 
  dev.off() 
 } 
   } 
   } 

We get the following errors: 
Error: unexpected symbol in: 
  text(0.5,0.5, text = paste(letters[i], +, 
numbers[j],=, letters [i+j+k]) 
  dev.off 
  } 
Error: unexpected '}' in  } 
} 
Error: unexpected '}' in} 
} 
Error: unexpected '}' in}
 
I hope you can figure out how to fix this..
Greetings
  
_


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Problems with code

2009-10-09 Thread Barry Rowlingson
On Fri, Oct 9, 2009 at 4:54 PM, Anne Buunk ann3bu...@hotmail.com wrote:
                          text(0.5,0.5, text = paste(letters[i], +, 
 numbers[j],=, letters [i+j+k])

Missing ) on the end there. You have one ( for text( and one for
paste( but only one ).

 Use an editor that matches parentheses, and read error messages to
figure out where things are going wrong.

Barry

__
R-help@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.