select()

select()

The select() function will select specific columns (variables) in a data frame. This may be useful when a data frame has many variables and you only want to take a look at a few of them together, or save a subset of variables as a new data frame.

NOTE: The select() function selects columns. To select specific rows, see the filter() function.

Idea
Example 1:

# Select only the columns for Thumb, Gender, and RaceEthnic in Fingers
# Optional: Use head() to truncate the output
head(select(Fingers, Thumb, Gender, RaceEthnic))

Example output:

output of head and select showing Thumb, Gender, and RaceEthnic

Idea
Example 2:

# Save a selected set of variables as a new data frame called Fingers_subset
Fingers_subset <- select(Fingers, Thumb, Index, Middle, Ring, Pinkie)
head(Fingers_subset)

Example output:
output of head showing Fingers_subset