length x <- numeric() x[3] <- 5 x [1] NA NA 5 [1] 3 x <- 1:5 length(x) <- 2 x [1] 1 2 https://cran.r-project.org/doc/manuals/r-release/R-intro.html#Changing-the-length-of-an-object-1