Lukas - 10 months ago 42

R Question

I'm sure this is really simple, but I can't get my head around how to vectorise this for loop

`x <- 1:3`

y <- 11:13

z <- x[1]

for(i in 2:length(x)){

tem <- x[i] + y[i-1]

z <- c(z, tem)

}

Source (Stackoverflow)