dplyr::select()
select(.data, ...) Returns:
tibble · Added in v1.0.0 · Updated March 13, 2026 · Tidyverse dplyr tidyverse data-wrangling select
select() is a dplyr verb that subsets columns from a data frame or tibble.
Syntax
select(.data, ...)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
.data | data.frame/tibble | — | A data frame or tibble to select from |
... | — | Column selections using names, positions, or helpers |
Examples
Basic column selection
Select specific columns by name:
library(dplyr)
df <- tibble(
id = 1:5,
name = c("Alice", "Bob", "Charlie", "Diana", "Eve"),
age = c(25, 30, 35, 28, 32),
salary = c(50000, 60000, 55000, 65000, 58000)
)
# Select two columns
select(df, name, age)
Using column positions
Select columns by their numeric positions:
# Select first and third columns
select(df, 1, 3)
Selection helpers
Use helper functions to select columns by pattern:
# Select columns that start with "s"
select(df, starts_with("s"))
# Select columns that contain "a"
select(df, contains("a"))
Renaming columns
Use = to rename while selecting:
select(df, ID = id, Employee = name)
Using everything() helper
Move specific columns to the front while keeping all others:
select(df, salary, everything())
Negative selection
Exclude specific columns using -:
select(df, -salary)
Common Patterns
Pipeline with select()
select() shines in dplyr pipelines:
df %>%
select(name, age) %>%
filter(age > 28) %>%
head(3)
Select numeric columns
# Select all numeric columns
df %>% select(where(is.numeric))
Reorder columns
Use select() to reorder columns for better readability:
select(df, name, age, salary, id)