Examples of data types

Date-time

datetime <- as.POSIXct("2025-09-27 10:30:00",
                       format = "%Y-%m-%d %H:%M:%S")
datetime
## [1] "2025-09-27 10:30:00 EDT"

Character(stores text)

Greeting <- ("Hi :)")
Greeting
## [1] "Hi :)"

Numeric (stores numbers)

Numeric <- 555
Numeric
## [1] 555

Boolean (True or False)

boolean1 <- TRUE
boolean1
## [1] TRUE

Array (store data in multiple dimensions)

array_ex <- array(1:8, dim= c(2,2,2))
array_ex
## , , 1
## 
##      [,1] [,2]
## [1,]    1    3
## [2,]    2    4
## 
## , , 2
## 
##      [,1] [,2]
## [1,]    5    7
## [2,]    6    8

Vector (stores multiple values of the same type)

vector_ex <- c(10,20,30,40)
vector_ex
## [1] 10 20 30 40

Data Frame (stores data in rows and coloumns)

dataframe_ex <- data.frame(
  Name = c("Sarah", "Tyson", "Marge"),
  Height = c(185, 154, 180))
dataframe_ex
##    Name Height
## 1 Sarah    185
## 2 Tyson    154
## 3 Marge    180

List (contains different types of data)

list_ex <- list(
  Name= "Tommy",
  Height= 186,
  Married= TRUE)
list_ex
## $Name
## [1] "Tommy"
## 
## $Height
## [1] 186
## 
## $Married
## [1] TRUE

Tibble (modern dataframe)

library(tibble)
## Warning: package 'tibble' was built under R version 4.4.3
tibble_ex <- tibble(
  Name = c("Sarah", "Tyson", "Marge"),
  Height = c(185, 154, 180))
tibble_ex
## # A tibble: 3 × 2
##   Name  Height
##   <chr>  <dbl>
## 1 Sarah    185
## 2 Tyson    154
## 3 Marge    180