Introduction

This document represents an empty R Markdown file (or Rmd file) for a LADAL tutorial. The R Markdown document for this tutorial can be downloaded here.

You will also have to download the bibliography file from https://slcladal.github.io/bibliography.bib for the tutorial to be knitted correctly. Although the knitted (or rendered) html file will look different from the LADAL design (because we have modified the theme for the LADAL page), it will be just like a proper LADAL tutorial once we have knitted the Rmd file on our machines and integrated your tutorial into the LADAL website.

Preparation and session set up

This tutorial is based on R. If you have not installed R or are new to it, you will find an introduction to and more information how to use R here. For this tutorials, we need to install certain packages from an R library so that the scripts shown below are executed without errors. Before turning to the code below, please install the packages by running the code below this paragraph. If you have already installed the packages mentioned below, then you can skip ahead and ignore this section. To install the necessary packages, simply run the following code - it may take some time (between 1 and 5 minutes to install all of the libraries so you do not need to worry if it takes some time).

# set options
options(stringsAsFactors = F)         # no automatic data transformation
options("scipen" = 100, "digits" = 4) # suppress math annotation
# install packages
install.packages("tidyverse")
install.packages("flextable")
# install klippy for copy-to-clipboard button in code chunks
remotes::install_github("rlesur/klippy")

Next, we activate the packages. Please include klippy in the installation and loading chunks to allow easy copy&pasting of code.

# activate packages
library(tidyverse)
library(flextable)
# activate klippy for copy-to-clipboard button
klippy::klippy()

Once you have installed R, RStudio, and have also initiated the session by executing the code shown above, you are good to go.

1 Tutorial content

Load some data and show what you want to show.

# load data
data <- base::readRDS(url("https://slcladal.github.io/data/sld.rda", "rb"))

Use flextable for displaying tabular data as shown below.

data %>%
  as.data.frame() %>%
  head(10) %>%
  flextable() %>%
  flextable::set_table_properties(width = .5, layout = "autofit") %>%
  flextable::theme_zebra() %>%
  flextable::fontsize(size = 12) %>%
  flextable::fontsize(size = 12, part = "header") %>%
  flextable::align_text_col(align = "center") %>%
  flextable::set_caption(caption = "")  %>%
  flextable::border_outer()

Below is the code chunk for exercises.


EXERCISE TIME!

`

  1. This is an example question.
Answer
  # this is some code
  1+1
  ## [1] 2

`


2 Remarks on type setting

Level 1 headers with numbers,, lower level headers without numbering (add {-} at the end of the header to suppress numbering).

Function and package names in package style (different from normal text).

Use italics for emphasis rather than bold type.

Citation & Session Info

Your last name, your first name. 2022. The title of your tutorial. Your location: your affiliation (in case you have one). url: https://slcladal.github.io/shorttitleofyourtutorial.html (Version 2022.05.24).

@manual{yourlastname2022net,
  author = {YourLastName, YourFirstName},
  title = {The title of your tutorials},
  note = {https://slcladal.github.io/shorttitleofyourtutorial.html},
  year = {2022},
  organization = {Your affiliation},
  address = {Your location},
  edition = {2022.05.24}
}
sessionInfo()
## R version 4.2.0 (2022-04-22 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19043)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8   
## [3] LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                   
## [5] LC_TIME=German_Germany.utf8    
## 
## attached base packages:
## [1] stats     graphics  grDevices datasets  utils     methods   base     
## 
## other attached packages:
##  [1] flextable_0.7.0 forcats_0.5.1   stringr_1.4.0   dplyr_1.0.9    
##  [5] purrr_0.3.4     readr_2.1.2     tidyr_1.2.0     tibble_3.1.7   
##  [9] ggplot2_3.3.6   tidyverse_1.3.1
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.8.3      lubridate_1.8.0   assertthat_0.2.1  digest_0.6.29    
##  [5] utf8_1.2.2        R6_2.5.1          cellranger_1.1.0  backports_1.4.1  
##  [9] reprex_2.0.1      evaluate_0.15     httr_1.4.3        highr_0.9        
## [13] pillar_1.7.0      gdtools_0.2.4     rlang_1.0.2       uuid_1.1-0       
## [17] readxl_1.4.0      rstudioapi_0.13   data.table_1.14.2 jquerylib_0.1.4  
## [21] klippy_0.0.0.9500 rmarkdown_2.14    munsell_0.5.0     broom_0.8.0      
## [25] compiler_4.2.0    modelr_0.1.8      xfun_0.30         systemfonts_1.0.4
## [29] pkgconfig_2.0.3   base64enc_0.1-3   htmltools_0.5.2   tidyselect_1.1.2 
## [33] fansi_1.0.3       crayon_1.5.1      tzdb_0.3.0        dbplyr_2.1.1     
## [37] withr_2.5.0       grid_4.2.0        jsonlite_1.8.0    gtable_0.3.0     
## [41] lifecycle_1.0.1   DBI_1.1.2         magrittr_2.0.3    scales_1.2.0     
## [45] zip_2.2.0         cli_3.3.0         stringi_1.7.6     renv_0.15.4      
## [49] fs_1.5.2          xml2_1.3.3        bslib_0.3.1       ellipsis_0.3.2   
## [53] generics_0.1.2    vctrs_0.4.1       tools_4.2.0       glue_1.6.2       
## [57] officer_0.4.2     hms_1.1.1         fastmap_1.1.0     yaml_2.3.5       
## [61] colorspace_2.0-3  rvest_1.0.2       knitr_1.39        haven_2.5.0      
## [65] sass_0.4.1

Back to top

Back to HOME


References