Menu

We can do both the Dplyr way and Base R way.

First, let’s create a sample dataset.

Case 1: Selecting One Column by Index Number

Case 2: Selecting One Column by Name

We can also simply spell out the name.

Case 3: Select Multiple Columns

Another way to select only the first 3 columns is to get rid of the fourth and fifth columns.

Or we can just specify the names too.