Reputation: 98
I want to do a loop for in R by multiplying the variable j by 2.
I use normally :
for (j in seq(0,10,2)){
#myloop
}
But this is used to add by 2 and not multiply.
Thanks in advance for your help.
Upvotes: 1
Views: 560
Reputation: 3188
Just create a geometric sequence
for (j in 2^(0:10)) {}
2^(0:10)
> [1] 1 2 4 8 16 32 64 128 256 512 1024
Upvotes: 3