caroline
caroline

Reputation: 98

R for loop with a multiplication by 2

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

Answers (1)

Vlo
Vlo

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

Related Questions