Data frames can be subset by column name. Selecting a column keeps the values aligned with their rows.

Program

Play the script to keep the name column and read its first value.

column_selection.R
people <- data.frame(name = c("Ada", "Lin"), age = c(36, 28), city = c("Paris", "Lima"))
names_only <- people["name"]
label <- names_only$name[1]
cat(label, "\n", sep = "")
column name `people["name"]` selects a column by name.
data frame subset Single-bracket column selection keeps a data frame result.
dollar access `names_only$name` reads one named column as a vector.