data.frame(), str(), head()

Data frames are the standard tabular structure — a list of equal-length vectors. Each column can have a different type. Essential inspection functions: str(), summary(), head(), dim(), colnames().

data
# Create
df <- data.frame(
  species = c("Gobio gobio", "Cottus perifretum", "Leuciscus leuciscus"),
  length_mm = c(82, 65, 110),
  weight_g  = c(5.2, 3.1, 14.8),
  threatened = c(FALSE, TRUE, FALSE)
)

# Inspect
str(df)
head(df, 2)
dim(df)          # rows, columns
nrow(df); ncol(df)
colnames(df)
summary(df)

# Access columns
df$species
df[["length_mm"]]

# Add / modify column
df$bmi <- df$weight_g / (df$length_mm / 10)^2

# Filter rows (base R)
df[df$threatened == TRUE, ]
subset(df, length_mm > 70)
# ── Example using iris ──────────────────────────────────────────
str(iris)
head(iris, 3)
dim(iris);  nrow(iris);  ncol(iris)
colnames(iris)
summary(iris)

# Add a column
iris$sepal_ratio <- iris$Sepal.Length / iris$Sepal.Width
head(iris[, c("Species","sepal_ratio")], 5)