Komplette Vorlesung: https://youtu.be/Vd3y_6hpvTM?list=PLw1QLhW9bTaJkeMbqWvjB2itOsNveMvwH
library(MASS)
?survey
attach(survey)
NW.Hnd: span of non-writing hand.
Wr.Hnd: span (distance from tip of thumb to tip of little finger of spread hand) of writing hand, in centimetres.
W.Hnd: writing hand of student. (Factor, with levels “Left” and “Right”.)
Clap: ‘Clap your hands! Which hand is on top?’ (Factor, with levels “Right”, “Left”, “Neither”.)
plot(Wr.Hnd, NW.Hnd, main = 'Linear regression',
xlab = "Span of writing hand", ylab = "Span of non-writing hand")
abline(lm(Wr.Hnd~NW.Hnd), col = 'red', lwd=3)
table(W.Hnd, Clap)
## Clap
## W.Hnd Left Neither Right
## Left 9 5 4
## Right 29 45 143
prop.table(table(W.Hnd, Clap))
## Clap
## W.Hnd Left Neither Right
## Left 0.03829787 0.02127660 0.01702128
## Right 0.12340426 0.19148936 0.60851064
barplot(prop.table(table(W.Hnd, Clap),2), legend.text = levels(W.Hnd), col = c('red', 'blue'))
fisher.test(table(W.Hnd, Clap))
##
## Fisher's Exact Test for Count Data
##
## data: table(W.Hnd, Clap)
## p-value = 0.0001413
## alternative hypothesis: two.sided