Next →

Output:


      

Plots:

Data Frames in R

Data frames are one of the most commonly used data structures in R for storing tabular data. Each column can have a different type, such as numeric, character, or factor.

Creating a Data Frame

students <- data.frame(
  name = c("Alice", "Bob", "Charlie"),
  age = c(23, 22, 24),
  grade = c("A", "B", "A")
)

Accessing Data

Tibbles

Tibbles are modern versions of data frames (from the tibble or tidyverse package) with better printing and subsetting behavior:

library(tibble)
students_tb <- tibble(
  name = c("Alice", "Bob", "Charlie"),
  age = c(23, 22, 24),
  grade = c("A", "B", "A")
)

Tibbles are especially helpful when working with large datasets in the tidyverse ecosystem.