This is the first part of an example data analysis. In this example we’ll do some basic data pre-processing and then export the dataset for use in the downstream analysis.
We’ll use the (outdated and not very exciting) mtcars dataset for this analysis. This consists of 11 variables for 32 car models build in 1973 and 1974. The first few rows of the dataset are shown in Table 1.
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb | |
---|---|---|---|---|---|---|---|---|---|---|---|
Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.5 | 0 | 1 | 4 | 4 |
Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 | 2.88 | 17 | 0 | 1 | 4 | 4 |
Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 | 2.32 | 18.6 | 1 | 1 | 4 | 1 |
Hornet 4 Drive | 21.4 | 6 | 258 | 110 | 3.08 | 3.21 | 19.4 | 1 | 0 | 3 | 1 |
Hornet Sportabout | 18.7 | 8 | 360 | 175 | 3.15 | 3.44 | 17 | 0 | 0 | 3 | 2 |
Valiant | 18.1 | 6 | 225 | 105 | 2.76 | 3.46 | 20.2 | 1 | 0 | 3 | 1 |
The only thing we’ll do for the purpose of this example is to add an additional column to indicate whether the car was build in the US or elsewhere.
international <- c(1:3, 8:14, 18:21, 26:28, 30:32)
ext_cars <- mtcars
ext_cars$origin <- 'US'
ext_cars$origin[international] <- 'international'
## Custom functions used in the analysis should go into this chunk.
## They will be listed in their own section of the appendix.
## This chunk should contain global configuration commands.
## Use this to set knitr options and related things. Everything
## in this chunk will be included in an appendix to document the
## configuration used.
## Pander options
panderOptions("digits", 3)
panderOptions("table.split.table", 160)
platform:
packages:
package | * | version | date | source |
---|---|---|---|---|
assertthat | 0.1 | 2013-12-06 | CRAN (R 3.3.1) | |
backports | 1.0.5 | 2017-01-18 | CRAN (R 3.3.2) | |
base64enc | 0.1-3 | 2015-07-28 | CRAN (R 3.3.0) | |
callr | 1.0.0.9000 | 2017-02-16 | Github (mangothecat/callr@c02300a) | |
codetools | 0.2-14 | 2015-07-15 | CRAN (R 3.3.1) | |
colorspace | 1.3-2 | 2016-12-14 | CRAN (R 3.3.2) | |
colourpicker | 0.3 | 2016-12-05 | CRAN (R 3.3.2) | |
DBI | 0.6 | 2017-03-09 | CRAN (R 3.3.3) | |
devtools | 1.12.0 | 2016-06-24 | CRAN (R 3.3.1) | |
digest | 0.6.12 | 2017-01-27 | CRAN (R 3.3.2) | |
dplyr | 0.5.0 | 2016-06-24 | CRAN (R 3.3.1) | |
evaluate | 0.10 | 2016-10-11 | CRAN (R 3.3.2) | |
ggplot2 | * | 2.2.1.9000 | 2017-03-16 | Github (tidyverse/ggplot2@08e135e) |
gtable | 0.2.0 | 2016-02-26 | CRAN (R 3.3.1) | |
htmltools | 0.3.5 | 2016-03-21 | CRAN (R 3.3.1) | |
htmlwidgets | 0.8 | 2016-11-09 | CRAN (R 3.3.2) | |
httpuv | 1.3.3 | 2015-08-04 | CRAN (R 3.3.2) | |
httr | 1.2.1 | 2016-07-03 | CRAN (R 3.3.1) | |
jsonlite | 1.3 | 2017-02-28 | CRAN (R 3.3.3) | |
knitr | * | 1.15.1 | 2016-11-22 | CRAN (R 3.3.2) |
lazyeval | 0.2.0 | 2016-06-12 | CRAN (R 3.3.1) | |
magrittr | 1.5 | 2014-11-22 | CRAN (R 3.3.1) | |
memoise | 1.0.0 | 2016-01-29 | CRAN (R 3.3.1) | |
mime | 0.5 | 2016-07-07 | CRAN (R 3.3.1) | |
miniUI | 0.1.1 | 2016-01-15 | CRAN (R 3.3.2) | |
munsell | 0.4.3 | 2016-02-13 | CRAN (R 3.3.1) | |
pander | * | 0.6.0 | 2015-11-23 | CRAN (R 3.3.1) |
plotly | * | 4.5.6.9000 | 2017-02-16 | Github (ropensci/plotly@cbf5885) |
plyr | 1.8.4 | 2016-06-08 | CRAN (R 3.3.1) | |
purrr | 0.2.2 | 2016-06-18 | CRAN (R 3.3.2) | |
R6 | 2.2.0 | 2016-10-05 | CRAN (R 3.3.2) | |
Rcpp | 0.12.9 | 2017-01-14 | CRAN (R 3.3.2) | |
reportMD | * | 0.4.0 | 2017-02-28 | local |
rmarkdown | 1.3 | 2016-12-21 | CRAN (R 3.3.2) | |
rprojroot | 1.2 | 2017-01-16 | CRAN (R 3.3.2) | |
scales | 0.4.1 | 2016-11-09 | CRAN (R 3.3.2) | |
shiny | 1.0.0 | 2017-01-12 | CRAN (R 3.3.2) | |
stringi | 1.1.2 | 2016-10-01 | CRAN (R 3.3.2) | |
stringr | 1.2.0 | 2017-02-18 | CRAN (R 3.3.3) | |
tibble | 1.2 | 2016-08-26 | CRAN (R 3.3.1) | |
tidyr | 0.6.1 | 2017-01-10 | CRAN (R 3.3.2) | |
viridisLite | 0.1.3 | 2016-03-12 | CRAN (R 3.3.2) | |
withr | 1.0.2 | 2016-06-20 | CRAN (R 3.3.1) | |
xml2 | 1.1.1 | 2017-01-24 | CRAN (R 3.3.2) | |
xtable | 1.8-2 | 2016-02-05 | CRAN (R 3.3.2) | |
yaml | 2.1.14 | 2016-11-12 | CRAN (R 3.3.2) |
File | Description |
---|---|
Table 1 | The mtcars dataset. |
Created with reportMD