--- title: "Visualisation: cars from three continents" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Visualisation: cars from three continents} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- The same dataset drawn eight ways, and what each view is able to show that the others are not. The other vignettes are listed by `vignette (package = "fdm2id")`; they use the same handful of functions on other data, and can be read in any order. ``` r library (fdm2id) ``` # The data 392 car models built on three continents (America, Asia and Europe). Beyond its origin, each car is described by six numeric attributes: fuel consumption, number of cylinders, displacement, horsepower, weight and acceleration. ``` r data (autompg) autompg = autompg [, -7] summary (autompg) #> mpg cylinders displacement horsepower weight #> Min. : 9.00 Min. :3.000 Min. : 68.0 Min. : 46.0 Min. :1613 #> 1st Qu.:17.00 1st Qu.:4.000 1st Qu.:105.0 1st Qu.: 75.0 1st Qu.:2225 #> Median :22.75 Median :4.000 Median :151.0 Median : 93.5 Median :2804 #> Mean :23.45 Mean :5.472 Mean :194.4 Mean :104.5 Mean :2978 #> 3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:275.8 3rd Qu.:126.0 3rd Qu.:3615 #> Max. :46.60 Max. :8.000 Max. :455.0 Max. :230.0 Max. :5140 #> acceleration origin #> Min. : 8.00 America:245 #> 1st Qu.:13.78 Europe : 68 #> Median :15.50 Asia : 79 #> Mean :15.54 #> 3rd Qu.:17.02 #> Max. :24.80 ``` # Question 1. Should the data be centred and scaled? ``` r apply (autompg [, -7], 2, sd) #> mpg cylinders displacement horsepower weight acceleration #> 7.805007 1.705783 104.644004 38.491160 849.402560 2.758864 ``` **Answer.** *The scales are very different -- `weight` against `acceleration` -- so yes.* ``` r autompg [, -7] = scale (autompg [, -7]) ``` # Question 2. What does each view of the data show? The same dataset, drawn eight ways. `plotdata` is the single entry point; `type` picks the view, and the origin of the cars colours the points throughout. ``` r plotdata (autompg, type = "pairs", labels = FALSE) ```
plot of chunk unnamed-chunk-6
plot of chunk unnamed-chunk-7
plot of chunk unnamed-chunk-8
plot of chunk unnamed-chunk-9
plot of chunk unnamed-chunk-10
plot of chunk unnamed-chunk-11
plot of chunk unnamed-chunk-12
plot of chunk unnamed-chunk-13