November 2017
Beginner to intermediate
204 pages
5h 23m
English
Individual columns can be selected from a dataframe using the $ symbol. The following selects the data from 2011 from the roads dataframe:
roads.2011 = roads$X2011
The resulting value is an R vector containing the values of the selected column.
Dataframes can also be indexed by row and column using the following syntax:
new.dataframe <- original.dataframe[<row_index>,<column index>].
To select all rows or all columns, the row_index or column_index can be left blank. For example:
the.same.thing <- roads[,]
The rows and columns indices can both be an integer value or a vector of integer values. For example:
first.three.rows <- roads[1:3,]first.three.columns <- roads[,1:3]
Row and column indices can also be a vector of ...
Read now
Unlock full access