elements_ <- c() # let's say this vector consists of 4 elements total_dim <- 4 # Using a for loop statement and the sequence function for (i in seq(total_dim)) { elements_[i] <- as.numeric(readline(paste("Enter element",i,": "))) }