To create a vector of integers in R, you can use the c() function or the colon operator.
In this example,
c()
function to create a vector of integers.c()
function combines these integers into a vector.int_vector
.int_vector <- c(1, 2, 3, 4, 5)
print(int_vector)
[1] 1 2 3 4 5
In this example,
:
to generate a sequence of integers from a starting value to an ending value.int_vector
.int_vector <- 1:5
print(int_vector)
[1] 1 2 3 4 5
In this tutorial, we learned How to create a Vector of Integers in R language with well detailed examples.