I assume that you are getting this error:
> mydata=matrix(nrow=1500,ncol=3)
> i=1
> for(x in 0:10){
+ for(y in 0:20){
+ for(z in 0:10){
+ mydata[i,]=c(x,y,z)
+ i=i+1
+ z=z+2}
+ y=y+4}
+ x=x+2}
Error in mydata[i, ] = c(x, y, z) : subscript out of bounds
No suitable frames for recover()
> i
[1] 1501
Dear Damien,
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of damien landais
> Sent: Friday, June 26, 2009 11:16 AM
> To: R-help@r-project.org
> Subject: [R] to raise in a loop more than 1
>
> I wo
I would raise x,y and z in a loop but I won't raise of 1. I tried this but it
doesn't work
mydata=matrix(nrow=1500,ncol=3)
i=1
for(x in 0:10){
for(y in 0:20){
for(z in 0:10){
mydata[i,]=c(x,y,z)
i=i+1
z=z+2}
y=y+4}
x=x+2}
And I would have something like that
x y z
0 0 0
0 0 2
0 0
3 matches
Mail list logo