dplyr-grammar.Rmd 13.45 KiB
title: "Einführung in dplyr-Grammatik"
subtitle: "Daten bändigen & visualisieren"
author: "B. Philipp Kleer"
date: "11. Oktober 2021"
output:
slidy_presentation:
slide_level: 3
footer: "Copyright: CC BY-SA 4.0, B. Philipp Kleer"
css: styles/style-slides.css
df_print: paged
highlight: espresso
library("knitr")
library("rmarkdown")
library("tidyverse")
uni <- readRDS("../datasets/uni.rds")
opts_chunk$set(fig.path = "pics/s6-", # path for calculated figures
fig.align = "center", # alignment of figure (also possible right, left, default)
fig.show = "hold", # how to show figures: hold -> direct at the end of code chunk; animate: all plots in an animation
fig.width = 3, # figure width
fig.height = 4, # figure height
echo = TRUE, # Code is printed
eval = FALSE, # Code is NOT evaluated
warning = FALSE, # warnings are NOT displayed
message = FALSE, # messages are NOT displayed
size = "tiny", # latex-size of code chunks
background = "#E7E7E7", # background color of code chunks
comment = "", # no hashtags before output
options(width = 80),
results = "markdown",
rows.print = 15
)
htmltools::tagList(
xaringanExtra::use_clipboard(
button_text = "<i class=\"fa fa-clipboard\"></i>",
success_text = "<i class=\"fa fa-check\" style=\"color: #90BE6D\"></i>",
error_text = "<i class=\"fa fa-times-circle\" style=\"color: #F94144\"></i>"
),
rmarkdown::html_dependency_font_awesome()
)
Starten wir!
Nun tauchen wir in die Welt von dplyr ein. Das Paket nutzt man oft, um Datenstrukturen zu erkunden oder Transformationen vorzunehmen. Dabei gibt es einen Grundstock an Vokabeln, die über piping miteinander verbunden werden.
Dazu installieren wir zuerst tidyverse:
install.packages("tidyverse")
library("tidyverse")
# alternativ:
# install.packages("dplyr")
# library("dplyr")
Anschließend laden wir den Datensatz uni
ins environment.
uni <- readRDS("../datasets/uni.rds") #oder eigener Pfad, wenn nicht in der Cloud
Wir verschaffen uns einen Überblick über den Datensatz:
uni