Lukas - 2 months ago 6x

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)

Comments