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/bibliogrpahy.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.
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!
`
Answer
# this is some code
1+1
## [1] 2
`
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.
Your last name, your first name. 2021. The title of your tutorial. Your location: your affiliation (in case you have one). url: https://slcladal.github.io/shorttitleofyourtutorial.html (Version 2021.10.02).
@manual{yourlastname2021net,
author = {YourLastName, YourFirstName},
title = {The title of your tutorials},
note = {https://slcladal.github.io/shorttitleofyourtutorial.html},
year = {2021},
organization = {Your affiliation},
address = {Your location},
edition = {2021.10.02}
}
sessionInfo()
## R version 4.1.1 (2021-08-10)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19043)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
## [4] LC_NUMERIC=C LC_TIME=German_Germany.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] flextable_0.6.8 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4 readr_2.0.1 tidyr_1.1.3
## [8] tibble_3.1.4 ggplot2_3.3.5 tidyverse_1.3.1
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.7 lubridate_1.7.10 assertthat_0.2.1 digest_0.6.27 utf8_1.2.2 R6_2.5.1
## [7] cellranger_1.1.0 backports_1.2.1 reprex_2.0.1.9000 evaluate_0.14 httr_1.4.2 highr_0.9
## [13] pillar_1.6.3 gdtools_0.2.3 rlang_0.4.11 uuid_0.1-4 readxl_1.3.1 rstudioapi_0.13
## [19] data.table_1.14.0 klippy_0.0.0.9500 rmarkdown_2.5 munsell_0.5.0 broom_0.7.9 compiler_4.1.1
## [25] modelr_0.1.8 xfun_0.26 pkgconfig_2.0.3 systemfonts_1.0.2 base64enc_0.1-3 htmltools_0.5.2
## [31] tidyselect_1.1.1 fansi_0.5.0 crayon_1.4.1 tzdb_0.1.2 dbplyr_2.1.1 withr_2.4.2
## [37] grid_4.1.1 jsonlite_1.7.2 gtable_0.3.0 lifecycle_1.0.1 DBI_1.1.1 magrittr_2.0.1
## [43] scales_1.1.1 zip_2.2.0 cli_3.0.1 stringi_1.7.4 fs_1.5.0 xml2_1.3.2
## [49] ellipsis_0.3.2 generics_0.1.0 vctrs_0.3.8 tools_4.1.1 glue_1.4.2 officer_0.4.0
## [55] hms_1.1.0 fastmap_1.1.0 yaml_2.2.1 colorspace_2.0-2 rvest_1.0.1 knitr_1.34
## [61] haven_2.4.3