Backup – Übung Boxplot

Überblick Lektion 1

Objekt mtcars:
Die Variable mtcars$hp (horsepower) enthält die PS Werte der Automodelle:
Bedienungshinweis

Bei Nutzung per Computer (nicht per Handy) können die beiden Fenster per Drag-and-Drop auch untereinander angeordnet werden. Das macht es übersichtlicher.

# no pec

mtcars
Demo IQR, Spannweite und Boxplot:
Quartilsabstand, Spannweite und Boxplot für die Variable mtcars$hp:
# no pec

cat("Sortierte Datenreihe:\n")
sort(mtcars$hp)
cat("\nQuartile:\n")
quantile(mtcars$hp)
Q1 <- quantile(mtcars$hp, 0.25) Q3 <- quantile(mtcars$hp, 0.75) cat("\nQuartilsabstand:", Q3, "-", Q1, "=", Q3-Q1 , "\n") IQR(mtcars$hp) cat("\nDer obere Fence ist bei: Q3 + 1.5*IQR =", Q3+1.5*IQR(mtcars$hp), "- aber Xmax ist bei:", max(mtcars$hp), "\n") cat("\nDie gesamte Spannweite ist:", max(mtcars$hp), "-", min(mtcars$hp), "=", max(mtcars$hp)-min(mtcars$hp), "\n") diff(range(mtcars$hp)) boxplot(mtcars$hp)
Boxplot alternativ mit ggplot:

ggplot Cheat Sheet

# no pec

library(ggplot2)
ggplot(mtcars, aes(x="", y=hp)) + stat_boxplot(geom="errorbar") + geom_boxplot()