[R] Odp: to raise in a loop more than 1

Petr PIKAL petr.pikal at precheza.cz
Fri Jun 26 12:13:41 CEST 2009


Hi

does

expand.grid(z=seq(0,6,2), y=seq(0,8,4), x=seq(0,10,2))

do what you want?

Petr

r-help-bounces at r-project.org napsal dne 26.06.2009 11:15:42:

> 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   4
> 0   0   6
> 0   0   8
> 0   0   10 
> 0   4   0
> 0   4   2
> ...
> 
> Could anybody help me?
> I don't work on a special package to do it...
> 
> Thanks
> 
> Cordialement
> Damien Landais
> 
> ______________________________________________
> 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