To create a vector of numbers from 1 to N in R, you can use the colon operator or the seq function.
In this example,
N <- 5
numbers <- 1:N
print(paste("Vector of numbers from 1 to", N, ":", numbers))
[1] "Vector of numbers from 1 to 5 : 1 2 3 4 5"
In this example,
N <- 5
numbers <- seq(1, N)
print(paste("Vector of numbers from 1 to", N, ":", numbers))
[1] "Vector of numbers from 1 to 5 : 1 2 3 4 5"
In this tutorial, we learned How to create a List of Numbers from 1 to N in R language with well detailed examples.