Notes

This report was generated on 2020-10-07 14:49:35. R version: 3.6.3 on x86_64-pc-linux-gnu. For this report, CRAN packages as of 2020-07-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 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.6.3 (2020-02-29)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.5 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
## LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
## 
## 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_2.3    sf_0.9-4         lintr_2.0.1      jsonlite_1.7.1  
##  [5] scales_1.1.1     readxl_1.3.1     magrittr_1.5     forcats_0.5.0   
##  [9] stringr_1.4.0    dplyr_1.0.0      purrr_0.3.4      readr_1.3.1     
## [13] tidyr_1.1.0      tibble_3.0.1     ggplot2_3.3.2    tidyverse_1.3.0 
## [17] checkpoint_0.4.0 rstudioapi_0.11  knitr_1.29      
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.4.6       lubridate_1.7.9    lattice_0.20-41    class_7.3-17      
##  [5] ps_1.3.3           assertthat_0.2.1   rprojroot_1.3-2    digest_0.6.25     
##  [9] R6_2.4.1           cellranger_1.1.0   backports_1.1.8    reprex_0.3.0      
## [13] e1071_1.7-3        evaluate_0.14      httr_1.4.2         pillar_1.4.4      
## [17] rlang_0.4.7        lazyeval_0.2.2     callr_3.4.4        blob_1.2.1        
## [21] desc_1.2.0         munsell_0.5.0      broom_0.5.6        compiler_3.6.3    
## [25] modelr_0.1.8       xfun_0.15          pkgconfig_2.0.3    htmltools_0.5.0   
## [29] tidyselect_1.1.0   fansi_0.4.1        crayon_1.3.4       dbplyr_1.4.4      
## [33] withr_2.2.0        grid_3.6.3         nlme_3.1-149       gtable_0.3.0      
## [37] lifecycle_0.2.0    DBI_1.1.0          units_0.6-7        KernSmooth_2.23-17
## [41] cli_2.0.2          stringi_1.4.6      fs_1.4.2           remotes_2.2.0     
## [45] rex_1.2.0          xml2_1.3.2         ellipsis_0.3.1     generics_0.0.2    
## [49] vctrs_0.3.1        cyclocomp_1.1.0    tools_3.6.3        glue_1.4.1        
## [53] hms_0.5.3          processx_3.4.2     yaml_2.2.1         colorspace_1.4-1  
## [57] classInt_0.4-3     rvest_0.3.5        haven_2.3.1

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()

Linting

The code in this RMarkdown is linted with the lintr package, which is based on the tidyverse style guide.

lintr::lint("main.Rmd", linters =
              lintr::with_defaults(
                commented_code_linter = NULL,
                trailing_whitespace_linter = NULL
                )
            )
# if you have additional scripts and want them to be linted too, add them here
# lintr::lint("scripts/my_script.R")