Rainbow Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Filtering by row
Extracting data by column
11. Select a range of columns
Practice using filter() and select()
The pipe operator
Sorting rows
Summary

Instruction

The dplyr package has lots of convenient ways to specify which columns to select. What if we want to select a range of columns? We'd use a colon (:) to define the columns we want. Important: Think of the colon as meaning "from ... to". For this operator to work, the columns we select must be in a continuous group.

So, if we wanted the first three columns in countries, we'd write:

select(countries, 1:3)

Exercise

Select columns three to five from countries.

Stuck? Here's a hint!

Type:

select(countries, 3:5)