12) Specifying columns of a Data Frame to return.

This Blog entry is from the Loading and Shaping section in Learn R.

The select() function returns just the columns specified after the data frame.  In this example, the AAPL data frame will be have some columns truncated leaving only the columns Interim_Buffer_Date and Interim_Close:

AAPL <- select(AAPL,Symbol,Interim_Buffer_Date,Interim_Close)
1.png

Run the line of script to console:

2.png

View the data frame:

View(AAPL)
3.png

Run the line of script to console:

4.png

It can be observed that the data frame has discarded columns that were not specified explicitly.