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

Date

Genre

Text

Prepositions

Region

1,736

Science

albin

166.01

North

1,711

Education

anon

139.86

North

1,808

PrivateLetter

austen

130.78

North

1,878

Education

bain

151.29

North

1,743

Education

barclay

145.72

North

1,908

Education

benson

120.77

North

1,906

Diary

benson

119.17

North

1,897

Philosophy

boethja

132.96

North

1,785

Philosophy

boethri

130.49

North

1,776

Diary

boswell

135.94

North

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. 2024. The title of your tutorial. Your location: your affiliation (in case you have one). url: https://slcladal.github.io/shorttitleofyourtutorial.html (Version 2024.04.09).

@manual{yourlastname2024net,
  author = {YourLastName, YourFirstName},
  title = {The title of your tutorials},
  note = {https://slcladal.github.io/shorttitleofyourtutorial.html},
  year = {2024},
  organization = {Your affiliation},
  address = {Your location},
  edition = {2024.04.09}
}
sessionInfo()
## R version 4.3.2 (2023-10-31 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 11 x64 (build 22621)
## 
## Matrix products: default
## 
## 
## locale:
## [1] LC_COLLATE=English_Australia.utf8  LC_CTYPE=English_Australia.utf8   
## [3] LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C                      
## [5] LC_TIME=English_Australia.utf8    
## 
## time zone: Australia/Brisbane
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] flextable_0.9.4 lubridate_1.9.3 forcats_1.0.0   stringr_1.5.1  
##  [5] dplyr_1.1.4     purrr_1.0.2     readr_2.1.5     tidyr_1.3.1    
##  [9] tibble_3.2.1    ggplot2_3.5.0   tidyverse_2.0.0
## 
## loaded via a namespace (and not attached):
##  [1] gtable_0.3.4            xfun_0.42               bslib_0.6.1            
##  [4] tzdb_0.4.0              vctrs_0.6.5             tools_4.3.2            
##  [7] generics_0.1.3          curl_5.2.0              klippy_0.0.0.9500      
## [10] fansi_1.0.6             highr_0.10              pkgconfig_2.0.3        
## [13] data.table_1.15.2       assertthat_0.2.1        uuid_1.2-0             
## [16] lifecycle_1.0.4         compiler_4.3.2          textshaping_0.3.7      
## [19] munsell_0.5.0           httpuv_1.6.14           fontquiver_0.2.1       
## [22] fontLiberation_0.1.0    htmltools_0.5.7         sass_0.4.8             
## [25] yaml_2.3.8              pillar_1.9.0            later_1.3.2            
## [28] crayon_1.5.2            jquerylib_0.1.4         gfonts_0.2.0           
## [31] ellipsis_0.3.2          openssl_2.1.1           cachem_1.0.8           
## [34] mime_0.12               fontBitstreamVera_0.1.1 zip_2.3.1              
## [37] tidyselect_1.2.1        digest_0.6.34           stringi_1.8.3          
## [40] fastmap_1.1.1           grid_4.3.2              colorspace_2.1-0       
## [43] cli_3.6.2               magrittr_2.0.3          crul_1.4.0             
## [46] utf8_1.2.4              withr_3.0.0             gdtools_0.3.6          
## [49] scales_1.3.0            promises_1.2.1          timechange_0.3.0       
## [52] rmarkdown_2.25          officer_0.6.5           askpass_1.2.0          
## [55] ragg_1.2.7              hms_1.1.3               shiny_1.8.0            
## [58] evaluate_0.23           knitr_1.45              rlang_1.1.3            
## [61] Rcpp_1.0.12             xtable_1.8-4            glue_1.7.0             
## [64] httpcode_0.3.0          xml2_1.3.6              rstudioapi_0.15.0      
## [67] jsonlite_1.8.8          R6_2.5.1                systemfonts_1.0.5

Back to top

Back to HOME


References