Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205372

How to make a vector using a for loop

$
0
0

I'm very new to R (and programming in general) and I've been stuck on this (probably very easy) question for a few days...

How would one make the vector 3 6 12 24 48 96 192 384 768 with a for loop?

All I've managed to come up with so far is something along the lines of:

x=numeric()
for (i in 1:8) (x=2*i[-1])

However, that doesn't work. I think one of the main problems is that I don't understand how to index numbers in a sequence.

If anyone could point me in the right direction that would be such a great help!


Viewing all articles
Browse latest Browse all 205372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>