Laden Sie die folgenden Packages und Data Frames:
library(tidyverse)## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3 ✓ purrr 0.3.4
## ✓ tibble 3.1.0 ✓ dplyr 1.0.5
## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(magrittr)##
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
##
## set_names
## The following object is masked from 'package:tidyr':
##
## extract
url <- "http://www.phonetik.uni-muenchen.de/~jmh/lehre/Rdf"
rating <- read.table(file.path(url, "rating.txt"))
preasp <- read.table(file.path(url, "preasp.txt"))
asp <- read.table(file.path(url, "asp.txt"))
vdata <- read.table(file.path(url, "vdata.txt"))dplyrvdur, clodur, vtype im Data Frame preasp dauerhaft um in vowelDuration, closureDuration und vowelType, und lassen Sie sich die Spaltennamen des Data Frames anzeigen.preasp %<>% rename(vowelDuration = vdur,
closureDuration = clodur,
vowelType = vtype)
preasp %>% colnames()## [1] "spk" "city" "region" "vowelDuration"
## [5] "predur" "closureDuration" "reldur" "clorel"
## [9] "preclorel" "vc" "cv" "vowelType"
## [13] "cplace" "ptonic" "word" "Pre"
vowelType) im Data Frame preasp mit den fünf höchsten Vokaldauern (vowelDuration) assoziiert sind. (Ergebnis ist ein Vektor mit 5 Elementen)preasp %>%
slice_max(vowelDuration, n = 5) %>%
pull(vowelType)## [1] "o" "o" "o" "o" "e"
cplace) im Data Frame preasp die maximale, minimale und durchschnittliche Verschlussdauer (closureDuration) und sortieren Sie das Ergebnis nach absteigender durchschnittlicher Verschlussdauer. (Ergebnis hat 3 Zeilen und 4 Spalten)preasp %>%
group_by(cplace) %>%
summarise(minimum = min(closureDuration),
maximum = max(closureDuration),
mittel = mean(closureDuration)) %>%
arrange(desc(mittel))## # A tibble: 3 x 4
## cplace minimum maximum mittel
## <chr> <dbl> <dbl> <dbl>
## 1 tt 0.0816 0.328 0.199
## 2 pp 0.111 0.279 0.181
## 3 kk 0.0373 0.313 0.155
preasp %>%
filter(vowelType == "a" & region != "C") %>%
group_by(region, city) %>%
summarise(stdabw = sd(vowelDuration))## `summarise()` has grouped output by 'region'. You can override using the `.groups` argument.
## # A tibble: 12 x 3
## # Groups: region [2]
## region city stdabw
## <chr> <chr> <dbl>
## 1 N bergamo 0.0301
## 2 N genova 0.0219
## 3 N milano 0.0304
## 4 N parma 0.0342
## 5 N torino 0.0341
## 6 N venezia 0.0247
## 7 S bari 0.0206
## 8 S cagliari 0.0296
## 9 S Catanzaro 0.0408
## 10 S lecce 0.0279
## 11 S napoli 0.0316
## 12 S palermo 0.0272
Vpn) das erste und dritte Quartil des Ratings im Data Frame rating. (Ergebnis hat 26 Zeilen und 3 Spalten)rating %>%
group_by(Vpn) %>%
summarise(Q1 = quantile(Rating, 0.25),
Q3 = quantile(Rating, 0.75))## # A tibble: 26 x 3
## Vpn Q1 Q3
## <chr> <dbl> <dbl>
## 1 S1 5.65 6.83
## 2 S10 5.33 6.50
## 3 S11 5.54 6.58
## 4 S12 3.58 6.08
## 5 S13 5.54 6.58
## 6 S14 2.71 5.46
## 7 S15 5.25 6.12
## 8 S16 5.3 6
## 9 S17 6.53 7
## 10 S18 4.96 5.87
## # … with 16 more rows
rating den Median und den Mittelwert der Ratings pro Sprache (Lang). (Ergebnis hat 2 Zeilen und 3 Spalten)rating %>%
slice(1:100) %>%
group_by(Lang) %>%
summarise(med = median(Rating),
mit = mean(Rating))## # A tibble: 2 x 3
## Lang med mit
## <chr> <dbl> <dbl>
## 1 E 6.5 6.36
## 2 S 6.33 6.29
Vpn) im Data Frame rating gibt. (Ergebnis hat 26 Zeilen und 2 Spalten)rating %>%
group_by(Vpn) %>%
summarise(count = n())## # A tibble: 26 x 2
## Vpn count
## <chr> <int>
## 1 S1 8
## 2 S10 8
## 3 S11 8
## 4 S12 8
## 5 S13 8
## 6 S14 8
## 7 S15 8
## 8 S16 8
## 9 S17 8
## 10 S18 8
## # … with 16 more rows
spk es pro Stadt, Region und Konsonant (cplace) im Data Frame preasp gibt (Ergebnis hat 45 Zeilen und 4 Spalten). Lassen Sie sich anschließend ausgeben, für welche Kombination(en) aus Stadt, Region und Konsonant es die wenigsten einzigartigen Sprecher gibt. Tipp: Hierfür müssen Sie sicherstellen, dass das Ergebnis des ersten Teils ein ungruppierter Data Frame ist.preasp %>%
group_by(city, region, cplace) %>%
summarise(count = n_distinct(spk)) %>%
ungroup() %>%
filter(count == min(count))## `summarise()` has grouped output by 'city', 'region'. You can override using the `.groups` argument.
## # A tibble: 1 x 4
## city region cplace count
## <chr> <chr> <chr> <int>
## 1 firenze C pp 6
# Alternative:
preasp %>%
group_by(city, region, cplace) %>%
summarise(count = n_distinct(spk), .groups = "drop") %>%
slice_min(count, n = 1)## # A tibble: 1 x 4
## city region cplace count
## <chr> <chr> <chr> <int>
## 1 firenze C pp 6
ggplot2asp, inwiefern der Konsonantentyp (Kons) von der Betonung (Bet) beeinflusst wird. Auf der x-Achse soll die Betonung angezeigt werden, die Füllfarbe der Balken soll sich nach dem Konsonantentyp richten. Die Balken sollen Proportionen anzeigen. Schreiben Sie unter Ihrem Code Ihre Einschätzung zu der Fragestellung als Kommentar auf.ggplot(asp) +
aes(x = Bet, fill = Kons) +
geom_bar(position = "fill")# Ihre Einschätzung:
# Der Konsonant k kommt deutlich häufiger in betonter Position vor,
# während der Konsonant t deutlich häufiger in unbetonter Position vorkommt.rating, wobei die Balken eine Breite von 0.5 haben und weiß umrandet sein sollen.ggplot(rating) +
aes(x = Rating) +
geom_histogram(binwidth = 0.5,
color = "white")ggplot(rating) +
aes(x = Rating, y = ..density..) +
geom_histogram(binwidth = 0.5,
color = "white")vdata, bei denen der Vokal (V) entweder “A” oder “I” oder “U” ist. F1 soll auf der y- und F2 auf der x-Achse sein.vdata %>%
filter(V %in% c("A", "I", "U")) %>%
ggplot() +
aes(x = F2, y = F1) +
geom_point()Subj) im Data Frame vdata. Fügen Sie dem Boxplot außerdem noch eine horizontale Linie bei 1500 Hz hinzu.ggplot(vdata) +
aes(x = Subj, y = F2) +
geom_boxplot() +
geom_hline(yintercept = 1500)preasp, bei dem die Region auf der x-Achse liegt und die Füllfarbe den Vokaltyp (vowelType) angibt. Es sollen hier nur Beobachtungen verwendet werden, für die die Vokaldauer vowelDuration zwischen 0.09 und 0.18 liegt. Die Balken sollen außerdem nebeneinander liegen.preasp %>%
filter(vowelDuration > 0.09 & vowelDuration < 0.18) %>%
ggplot() +
aes(x = region, fill = vowelType) +
geom_bar(position = "dodge")