r - Filling an empty vector -


here's super newbie question. i'm working through art of r programming , came across simple code:

z <- null  (i in 1:10) if (i %% 2 == 0) z <- c(z,i) z 

the output c(2,4,6,8,10).

what don't understand why need c(z,i) populate vector z. why wouldn't c(i) work. when that, skips straight last iteration , fills vector z last associated value. there form of rule governs populating vectors? try might, didn't find clear answer anywhere, bunch of samples that, while made sense, didn't me solve above.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -