The Beginning

This is an example with a bit of code:

x=20.4879 # create a value x
format(round(x, 2), nsmall = 2) # to round x to 2 decimals
## [1] "20.49"
format(round(x, 1), nsmall = 1) # to round x to 1 decimal
## [1] "20.5"

Example 1

Thank you for accepting me into the course!

Example 2

… and a table.

Table 1: Descriptives for the students of group 1 and 2

Mean SD Min Max
Group 1 9 3 3 15
Group 2 10 3 3 17

Simple Calculation

1+2
## [1] 3

Chapter 2

This chapter is actually not that interesting.

Section 1

data <- read.csv(file="regional_language_data-new.csv",
head=TRUE, sep=";")

Section 2

head(data) # this will show you the first 6 lines
tail(data) # this will show you the last 6 lines
str(data)
## 'data.frame':    150 obs. of  8 variables:
##  $ ID             : int  91 139 13 78 94 25 80 122 18 29 ...
##  $ age            : int  70 61 74 77 76 71 71 72 61 63 ...
##  $ gender         : chr  "female" "female" "female" "female" ...
##  $ education_level: chr  "middle" "middle" "middle" "middle" ...
##  $ group          : chr  "Frisian-Dutch" "Frisian-Dutch" "Frisian-Dutch" "LowSaxon-Dutch" ...
##  $ numb_lang      : int  2 2 2 2 2 2 2 2 2 3 ...
##  $ rel_prof       : num  0.12 0.64 0.27 0.35 0.25 0.63 0.24 0.1 0.79 0.06 ...
##  $ score          : int  62 64 68 71 76 77 78 81 96 64 ...

Section 3

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
data <- data %>%
mutate_if(is.character, as.factor) %>%
mutate(ID = as.factor(ID))
data$education_level = factor(data$education_level,levels
= c("lower", "middle", "higher"))
names(data)[names(data) == "education_level"] <- "literacy"

Task 1-3 - Descriptives, plots and figures

Mean per group

aggregate(score ~ group, data, mean)
boxplot(score ~ group, data=data, main="Title Plot", xlab="Group", ylab="Score")

Frisian <- subset(data, group == "Frisian-Dutch")
LowSaxon <- subset(data, group == "LowSaxon-Dutch")
hist(Frisian$score, main = "Frisian", xlab = "Score",prob=TRUE)
curve(dnorm(x, mean=mean(Frisian$score),
sd=sd(Frisian$score)), add=TRUE)

hist(LowSaxon$score, main = "LowSaxon", xlab = "Score",prob=TRUE)
curve(dnorm(x, mean=mean(LowSaxon$score),
sd=sd(LowSaxon$score)), add=TRUE)

col = '#03a884' # this is the color used in the slides
ggplot(data, aes(x = gender)) + geom_bar()