Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR R

how to read a vector input in r

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,": ")))
}
 
PREVIOUS NEXT
Tagged: #read #vector #input
ADD COMMENT
Topic
Name
6+4 =