library(tidyverse)
library(easystats)mariokart-korr1
datawrangling
dplyr
eda
association
num
Aufgabe
Importieren Sie den Datensatz mariokart in R. Berechnen Sie die Korrelation von Verkaufspreis (total_pr) und Startgebot (start_pr)!
Hinweise:
- Runden Sie auf 2 Dezimalstellen.
Lösung
Pakete starten:
Daten importieren:
d_url <- "https://vincentarelbundock.github.io/Rdatasets/csv/openintro/mariokart.csv"
d <- data_read(d_url)solution <-
d %>%
summarise(pr_cor = cor(total_pr, start_pr))
solution| pr_cor |
|---|
| 0.073406 |
Alternativ kann man (komfortabel) die Korrelation z.B. so berechnen:
d %>%
select(start_pr, total_pr) %>%
correlation()| Parameter1 | Parameter2 | r | CI | CI_low | CI_high | t | df_error | p | Method | n_Obs |
|---|---|---|---|---|---|---|---|---|---|---|
| start_pr | total_pr | 0.073406 | 0.95 | -0.0918493 | 0.2347263 | 0.8740063 | 141 | 0.383601 | Pearson correlation | 143 |
Man kann das Ergebnis von correlation auch einfach in ein Diagramm überführen:
mariokart_corr1 <-
d %>%
select(start_pr, total_pr) %>%
correlation()
mariokart_corr1 %>% plot()
Lösung: 0.07.
Categories:
- datawrangling
- dplyr
- eda
- association
- num