Notes

This report was generated on 2019-08-08 09:56:07. R version: 3.5.3 on x86_64-pc-linux-gnu. For this report, CRAN packages as of 2019-03-01 were used.

R-Script & data

The preprocessing and analysis of the data was conducted in the R project for statistical computing. The RMarkdown script used to generate this document and all the resulting data can be downloaded under this link. Through executing main.Rmd, the herein described process can be reproduced and this document can be generated. In the course of this, data from the folder ìnput will be processed and results will be written to output.

GitHub

The code for the herein described process can also be freely downloaded from https://github.com/grssnbchr/rddj-template.

License

Data description of output files

abc.csv (Example)

Attribute Type Description
a Numeric
b Numeric
c Numeric

xyz.csv

Preparations

## [1] "package package:rmarkdown detached"
## Loading required package: knitr
## Loading required package: rstudioapi

Define packages

# from https://mran.revolutionanalytics.com/web/packages/checkpoint/vignettes/using-checkpoint-with-knitr.html
# if you don't need a package, remove it from here (commenting is probably not sufficient)
# tidyverse: see https://blog.rstudio.org/2016/09/15/tidyverse-1-0-0/
cat("
library(rstudioapi)
library(tidyverse) # ggplot2, dplyr, tidyr, readr, purrr, tibble
library(magrittr) # pipes
library(readxl) # excel
library(scales) # scales for ggplot2
library(jsonlite) # json
library(lintr) # code linting
library(sf) # spatial data handling
library(rmarkdown)",
file = "manifest.R")

Install packages

# if checkpoint is not yet installed, install it (for people using this
# system for the first time)
if (!require(checkpoint)) {
  if (!require(devtools)) {
    install.packages("devtools", repos = "http://cran.us.r-project.org")
    require(devtools)
  }
  devtools::install_github("RevolutionAnalytics/checkpoint",
                           ref = "v0.3.2", # could be adapted later,
                           # as of now (beginning of July 2017
                           # this is the current release on CRAN)
                           repos = "http://cran.us.r-project.org")
  require(checkpoint)
}
# nolint start
if (!dir.exists("~/.checkpoint")) {
  dir.create("~/.checkpoint")
}
# nolint end
# install packages for the specified CRAN snapshot date
checkpoint(snapshotDate = package_date,
           project = path_to_wd,
           verbose = T,
           scanForPackages = T,
           use.knitr = F,
           R.version = R_version)
rm(package_date)

Load packages

source("manifest.R")
unlink("manifest.R")
sessionInfo()
## R version 3.5.3 (2019-03-11)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.2 LTS
## 
## Matrix products: default
## BLAS: /opt/R/R-3.5.3/lib/R/lib/libRblas.so
## LAPACK: /opt/R/R-3.5.3/lib/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=de_CH.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=de_CH.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=de_CH.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] rmarkdown_1.11   sf_0.7-3         lintr_1.0.3      jsonlite_1.6    
##  [5] scales_1.0.0     readxl_1.3.0     magrittr_1.5     forcats_0.4.0   
##  [9] stringr_1.4.0    dplyr_0.8.0.1    purrr_0.3.0      readr_1.3.1     
## [13] tidyr_0.8.2      tibble_2.0.1     ggplot2_3.1.0    tidyverse_1.2.1 
## [17] checkpoint_0.4.0 rstudioapi_0.9.0 knitr_1.21      
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_0.2.5 xfun_0.5         haven_2.1.0      lattice_0.20-38 
##  [5] colorspace_1.4-0 generics_0.0.2   htmltools_0.3.6  yaml_2.2.0      
##  [9] rlang_0.3.1      e1071_1.7-0.1    pillar_1.3.1     glue_1.3.0      
## [13] withr_2.1.2      DBI_1.0.0        modelr_0.1.4     plyr_1.8.4      
## [17] munsell_0.5.0    gtable_0.2.0     cellranger_1.1.0 rvest_0.3.2     
## [21] evaluate_0.13    rex_1.1.2        class_7.3-15     broom_0.5.1     
## [25] Rcpp_1.0.0       backports_1.1.3  classInt_0.3-1   hms_0.4.2       
## [29] digest_0.6.18    stringi_1.3.1    grid_3.5.3       cli_1.0.1       
## [33] tools_3.5.3      lazyeval_0.2.1   crayon_1.3.4     pkgconfig_2.0.2 
## [37] xml2_1.2.0       lubridate_1.7.4  assertthat_0.2.0 httr_1.4.0      
## [41] R6_2.4.0         units_0.6-2      nlme_3.1-137     compiler_3.5.3

Load additional scripts

# if you want to outsource logic to other script files, see README for 
# further information
knitr::read_chunk("scripts/my_script.R")
source("scripts/my_script.R")
my_function(5)
## [1] 5

IO test

x <- read.csv2("input/test.csv", sep = ",")
x
##   a b c
## 1 1 2 3
## 2 4 5 6
write.csv2(x, "output/abc.csv", row.names = F)
write.csv2(x, "output/xyz.csv", row.names = F)
# the following file would be ignored by Git if saved into the ignore folder
# see README for further information
# write.csv2(x, "output/ignore/fgh.csv", row.names = F)

Some plot

set.seed(123)
x <- rnorm(1000)
y <- x * 2 + rnorm(1000)
df <- data.frame(x, y)
ggplot(df) +
  geom_point(aes(x = x, y = y)) +
  geom_smooth(aes(x = x, y = y)) +
  labs(title = "The correlation between x and y", 
       subtitle = "A ggplot2 approach", 
       caption = "source: a pseudo-number generator with seed 123") +
  theme_minimal()