Vector in R

Vector is a data structure in R which is of fixed type and fixed length.

It contains elements of the same type at each index. The data types can be

  • Logical
  • Integer
  • Numeric
  • Character
  • Complex


Vectors of different types


realNumericVector <- c(1, 2, 3, 4) # numeric


decimalNumericVector <- c(0.1, 0.2, 0.3, 0.4) # numeric


logiacalVector <- c(TRUE, FALSE) # logical


characterVector <- c(“a”, “b”, “c”) # character


integerVector <- 1:9 # integer


myComplexVector <- c(1+1i, 2+2i) # complex

Leave a Reply