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/content/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
install.packages("remotes")
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.09.13).

@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.09.13}
}
sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.1 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8    
##  [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8   
##  [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices datasets  utils     methods   base     
## 
## other attached packages:
##  [1] flextable_0.7.3 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.2
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.8.3        lubridate_1.8.0     assertthat_0.2.1   
##  [4] digest_0.6.29       utf8_1.2.2          R6_2.5.1           
##  [7] cellranger_1.1.0    backports_1.4.1     reprex_2.0.1       
## [10] evaluate_0.15       httr_1.4.3          highr_0.9          
## [13] pillar_1.7.0        gdtools_0.2.4       rlang_1.0.4        
## [16] uuid_1.1-0          googlesheets4_1.0.0 readxl_1.4.0       
## [19] data.table_1.14.2   jquerylib_0.1.4     klippy_0.0.0.9500  
## [22] rmarkdown_2.14      googledrive_2.0.0   munsell_0.5.0      
## [25] broom_1.0.0         compiler_4.2.1      modelr_0.1.8       
## [28] xfun_0.31           systemfonts_1.0.4   base64enc_0.1-3    
## [31] pkgconfig_2.0.3     htmltools_0.5.2     tidyselect_1.1.2   
## [34] fansi_1.0.3         crayon_1.5.1        tzdb_0.3.0         
## [37] dbplyr_2.2.1        withr_2.5.0         grid_4.2.1         
## [40] jsonlite_1.8.0      gtable_0.3.0        lifecycle_1.0.1    
## [43] DBI_1.1.3           magrittr_2.0.3      scales_1.2.0       
## [46] zip_2.2.0           cli_3.3.0           stringi_1.7.8      
## [49] renv_0.15.4         fs_1.5.2            xml2_1.3.3         
## [52] bslib_0.3.1         ellipsis_0.3.2      generics_0.1.3     
## [55] vctrs_0.4.1         tools_4.2.1         glue_1.6.2         
## [58] officer_0.4.3       hms_1.1.1           fastmap_1.1.0      
## [61] yaml_2.3.5          colorspace_2.0-3    gargle_1.2.0       
## [64] rvest_1.0.2         knitr_1.39          haven_2.5.0        
## [67] sass_0.4.1

Back to top

Back to HOME


References