D Data Frame Wrangling in R

R data.frames are similar to matrices in the sense that we use them to store tabular data. However, in data frames each column can be of different type:

##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1          5.1         3.5          1.4         0.2  setosa
## 2          4.9         3.0          1.4         0.2  setosa
## 3          4.7         3.2          1.3         0.2  setosa
## 4          4.6         3.1          1.5         0.2  setosa
## 5          5.0         3.6          1.4         0.2  setosa
## 6          5.4         3.9          1.7         0.4  setosa
##               Country Disp Disp2 Eng.Rev Front.Hd Frt.Leg.Room
## Acura Integra   Japan  112   1.8    2935      3.5         41.5
## Acura Legend    Japan  163   2.7    2505      2.0         41.5
##               Frt.Shld Gear.Ratio Gear2  HP HP.revs Height
## Acura Integra     53.0       3.26  3.21 130    6000   47.5
## Acura Legend      55.5       2.95  3.02 160    5900   50.0
##               Length Luggage Mileage Model2 Price Rear.Hd
## Acura Integra    177      16      NA        11950     1.5
## Acura Legend     191      14      20        24760     2.0
##               Rear.Seating RearShld Reliability Rim Sratio.m
## Acura Integra         26.5     52.0 Much better R14       NA
## Acura Legend          28.5     55.5 Much better R15       NA
##               Sratio.p Steering Tank  Tires Trans1 Trans2
## Acura Integra     0.86    power 13.2 195/60  man.5 auto.4
## Acura Legend      0.96    power 18.0 205/60  man.5 auto.4
##               Turning   Type Weight Wheel.base Width
## Acura Integra      37  Small   2700        102    67
## Acura Legend       42 Medium   3265        109    69