How to generate vector of integer in R



I want to generate the vector of integers in R but I am getting the vector of numeric
[1] “numeric”


You can use Z <- 1:4 or any sequence with the seq(1, 4) type of function using integers as arguments.

Or you can coerce the existing object to class “integer” with Z2 <- as.integer(Z).

A third option is to specify integer values with a capital letter “L” attached to each number: Z <- c(1L, 2L, 3L, 4L).