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
<- "http://www.phonetik.uni-muenchen.de/~jmh/lehre/Rdf"
url <- read.table(file.path(url, "rating.txt")) %>% as_tibble()
rating <- read.table(file.path(url, "preasp.txt")) %>% as_tibble()
preasp <- read.table(file.path(url, "vcvC.txt")) %>% as_tibble()
vcv <- read.table(file.path(url, "vdata.txt")) %>% as_tibble()
vdata <- read.csv(file.path(url, "hp_looks.txt"), sep="") %>% as_tibble()
hp_looks <- read.csv(file.path(url, "hp_measures.txt"), sep="") %>% as_tibble()
hp_measures <- read.csv(file.path(url, "hp_meta.txt"), sep="") %>% as_tibble()
hp_meta <- read.csv(file.path(url, "hp_names.txt"), sep="") %>% as_tibble()
hp_names <- read.csv(file.path(url, "hp_wiz.txt"), sep="") %>% as_tibble()
hp_wiz <- read.table(file.path(url, "param.txt"), stringsAsFactors = F) %>%
p ::filter(nchar(Vpn) > 4) %>%
dplyras_tibble()
dplyr
& tidyr
x
, y
und z
im Data Frame diamonds
(wird automatisch mit dem tidyverse geladen) um in laenge
, breite
und tiefe
. Erstellen Sie dann durch pivoting eine neue Spalte measure
aus den drei umbenannten Spalten und eine neue Spalte value
, die deren Werte enthält.%>%
diamonds rename(laenge = x,
breite = y,
tiefe = z) %>%
pivot_longer(cols = c(laenge, breite, tiefe),
names_to = "measure",
values_to = "value")
## # A tibble: 161,820 x 9
## carat cut color clarity depth table price measure value
## <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <chr> <dbl>
## 1 0.23 Ideal E SI2 61.5 55 326 laenge 3.95
## 2 0.23 Ideal E SI2 61.5 55 326 breite 3.98
## 3 0.23 Ideal E SI2 61.5 55 326 tiefe 2.43
## 4 0.21 Premium E SI1 59.8 61 326 laenge 3.89
## 5 0.21 Premium E SI1 59.8 61 326 breite 3.84
## 6 0.21 Premium E SI1 59.8 61 326 tiefe 2.31
## 7 0.23 Good E VS1 56.9 65 327 laenge 4.05
## 8 0.23 Good E VS1 56.9 65 327 breite 4.07
## 9 0.23 Good E VS1 56.9 65 327 tiefe 2.31
## 10 0.29 Premium I VS2 62.4 58 334 laenge 4.2
## # … with 161,810 more rows
Vpn
des Data Frames p
befinden sich drei Informationen: Alter, Region und Staat, getrennt durch Unterstriche. Teilen Sie die Informationen dauerhaft in drei neue, sinnvoll benannte Spalten auf.%<>%
p separate(col = "Vpn",
into = c("age", "region", "country"),
sep = "_")
p
alle Beobachtungen ausgeben, wo die Versuchsperson zwischen 85 und 90 Jahren alt, der Context Cont
“mie” und der Messwert slopes
größer oder gleich 1.0 ist. (Ergebnis hat 2 Zeilen und 6 Spalten)%>% filter(age > 85 & age < 90 &
p == "mie" &
Cont >= 1.0) slopes
## # A tibble: 2 x 6
## slopes age region country Group Cont
## <dbl> <chr> <chr> <chr> <chr> <chr>
## 1 1.08 87 2 de Stand mie
## 2 1.08 88 2 de Stand mie
vdata
die Spalten F1
bis Cons
aus sowie alle Beobachtungen, für die die Versuchsperson Subj
nicht “bk” oder “hp” oder “ta” ist; formen Sie den Data Frame dann so um, dass die Formanten F1 und F2 in einer neuen Spalte formant
und die F1- und F2-Werte in einer neuen Spalte value
erscheinen. (Ergebnis hat 3424 Zeilen und 6 Spalten)%>%
vdata filter(!Subj %in% c("bk", "hp", "ta")) %>%
select(F1:Cons) %>%
pivot_longer(cols = c(F1, F2), names_to = "formant", values_to = "value")
## # A tibble: 3,424 x 6
## dur V Tense Cons formant value
## <dbl> <chr> <chr> <chr> <chr> <int>
## 1 102. E - K F1 465
## 2 102. E - K F2 1786
## 3 95.7 % - P F1 497
## 4 95.7 % - P F2 1211
## 5 96.6 I - T F1 342
## 6 96.6 I - T F2 1591
## 7 95.1 Y - K F1 300
## 8 95.1 Y - K F2 1450
## 9 129. E - T F1 411
## 10 129. E - T F2 1536
## # … with 3,414 more rows
RT
pro Versuchsperson Subject
, Vokal Vowel
und Sprache Lang
im Data Frame vcv
heraus. Fügen Sie dem daraus resultierenden Data Frame eine Spalte namens tempo
hinzu, die folgende Werte enthält: “schnell” für alle mittleren Reaktionszeiten unter 500 ms, “mittel” für Reaktionszeiten zwischen 500 und 575 ms, “okay” für Reaktionszeiten zwischen 575 und 650 ms, “langsam” für Reaktionszeiten zwischen 650 und 800 ms, und “sehr langsam” für alle Reaktionszeiten über 800 ms. Finden Sie anschließend heraus, wie häufig jeder Wert der Variable tempo
vorkommt. (Ergebnis hat 5 Zeilen und 2 Spalten)%>%
vcv group_by(Subject, Vowel, Lang) %>%
summarise(mean_rt = mean(RT)) %>%
mutate(tempo = case_when(mean_rt < 500 ~ "schnell",
> 500 & mean_rt < 575 ~ "mittel",
mean_rt > 575 & mean_rt < 650 ~ "okay",
mean_rt > 650 & mean_rt < 800 ~ "langsam",
mean_rt > 800 ~ "sehr langsam")) %>%
mean_rt group_by(tempo) %>%
summarise(count = n())
## `summarise()` has grouped output by 'Subject', 'Vowel'. You can override using the `.groups` argument.
## # A tibble: 5 x 2
## tempo count
## <chr> <int>
## 1 langsam 29
## 2 mittel 7
## 3 okay 9
## 4 schnell 5
## 5 sehr langsam 4
dplyr
hp_names
und hp_meta
so miteinander, dass alle Beobachtungen und alle Spalten aus beiden Data Frames im Ergebnis erhalten bleiben. Nutzen Sie die Spalte id
als key. Es gibt hier verschiedene Lösungswege.inner_join(hp_names, hp_meta, by = "id")
## # A tibble: 140 x 7
## id name gender species bloodStatus birth death
## <int> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1 Harry James Po… Male Human Half-blood "31 July 198… <NA>
## 2 2 Ronald Bilius … Male Human Pure-blood "1 March 198… <NA>
## 3 3 Hermione Jean … Female Human Muggle-born "19 Septembe… <NA>
## 4 4 Albus Percival… Male Human Half-blood "Late August… "30 Ju…
## 5 5 Rubeus Hagrid Male Half-Human… Part-Human (H… "6 December … <NA>
## 6 6 Neville Longbo… Male Human Pure-blood "30 July, 19… <NA>
## 7 7 Fred Weasley Male Human Pure-blood "1 April, 19… "2 May…
## 8 8 George Weasley Male Human Pure-blood " 1 April, 1… <NA>
## 9 9 Ginevra (Ginny… Female Human Pure-blood "11 August, … <NA>
## 10 10 Dean Thomas Male Human Muggle-born " 1 Septembe… <NA>
## # … with 130 more rows
full_join(hp_names, hp_meta, by = "id")
## # A tibble: 140 x 7
## id name gender species bloodStatus birth death
## <int> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1 Harry James Po… Male Human Half-blood "31 July 198… <NA>
## 2 2 Ronald Bilius … Male Human Pure-blood "1 March 198… <NA>
## 3 3 Hermione Jean … Female Human Muggle-born "19 Septembe… <NA>
## 4 4 Albus Percival… Male Human Half-blood "Late August… "30 Ju…
## 5 5 Rubeus Hagrid Male Half-Human… Part-Human (H… "6 December … <NA>
## 6 6 Neville Longbo… Male Human Pure-blood "30 July, 19… <NA>
## 7 7 Fred Weasley Male Human Pure-blood "1 April, 19… "2 May…
## 8 8 George Weasley Male Human Pure-blood " 1 April, 1… <NA>
## 9 9 Ginevra (Ginny… Female Human Pure-blood "11 August, … <NA>
## 10 10 Dean Thomas Male Human Muggle-born " 1 Septembe… <NA>
## # … with 130 more rows
left_join(hp_names, hp_meta, by = "id")
## # A tibble: 140 x 7
## id name gender species bloodStatus birth death
## <int> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1 Harry James Po… Male Human Half-blood "31 July 198… <NA>
## 2 2 Ronald Bilius … Male Human Pure-blood "1 March 198… <NA>
## 3 3 Hermione Jean … Female Human Muggle-born "19 Septembe… <NA>
## 4 4 Albus Percival… Male Human Half-blood "Late August… "30 Ju…
## 5 5 Rubeus Hagrid Male Half-Human… Part-Human (H… "6 December … <NA>
## 6 6 Neville Longbo… Male Human Pure-blood "30 July, 19… <NA>
## 7 7 Fred Weasley Male Human Pure-blood "1 April, 19… "2 May…
## 8 8 George Weasley Male Human Pure-blood " 1 April, 1… <NA>
## 9 9 Ginevra (Ginny… Female Human Pure-blood "11 August, … <NA>
## 10 10 Dean Thomas Male Human Muggle-born " 1 Septembe… <NA>
## # … with 130 more rows
right_join(hp_meta, hp_names, by = "id")
## # A tibble: 140 x 7
## id gender species bloodStatus birth death name
## <int> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1 Male Human Half-blood "31 July 198… <NA> Harry James P…
## 2 2 Male Human Pure-blood "1 March 198… <NA> Ronald Bilius…
## 3 3 Female Human Muggle-born "19 Septembe… <NA> Hermione Jean…
## 4 4 Male Human Half-blood "Late August… "30 Ju… Albus Perciva…
## 5 5 Male Half-Human… Part-Human (Ha… "6 December … <NA> Rubeus Hagrid
## 6 6 Male Human Pure-blood "30 July, 19… <NA> Neville Longb…
## 7 7 Male Human Pure-blood "1 April, 19… "2 May… Fred Weasley
## 8 8 Male Human Pure-blood " 1 April, 1… <NA> George Weasley
## 9 9 Female Human Pure-blood "11 August, … <NA> Ginevra (Ginn…
## 10 10 Male Human Muggle-born " 1 Septembe… <NA> Dean Thomas
## # … with 130 more rows
hp_names
und hp_wiz
über die Spalte id
, sodass nur Zeilen aus hp_wiz
erhalten bleiben und das Ergebnis die Spalten beider Data Frames enthält. Es gibt hier verschiedene Lösungswege.inner_join(hp_names, hp_wiz, by = "id")
## # A tibble: 97 x 5
## id name house wand patronus
## <int> <chr> <chr> <chr> <chr>
## 1 1 Harry James Potter Gryffin… "11\" Holly phoenix… Stag
## 2 2 Ronald Bilius Weasley Gryffin… "12\" Ash unicorn tai… Jack Russell …
## 3 3 Hermione Jean Granger Gryffin… "10¾\" vine wood dra… Otter
## 4 4 Albus Percival Wulfric … Gryffin… "15\" Elder Thestral … Phoenix
## 5 5 Rubeus Hagrid Gryffin… "16\" Oak unknown co… None
## 6 6 Neville Longbottom Gryffin… "13\" Cherry unicorn … Non-corporeal
## 7 7 Fred Weasley Gryffin… "Unknown" Unknown
## 8 8 George Weasley Gryffin… "Unknown" Unknown
## 9 9 Ginevra (Ginny) Molly W… Gryffin… "Unknown" Horse
## 10 10 Dean Thomas Gryffin… "Unknown" Unknown
## # … with 87 more rows
right_join(hp_names, hp_wiz, by = "id")
## # A tibble: 97 x 5
## id name house wand patronus
## <int> <chr> <chr> <chr> <chr>
## 1 1 Harry James Potter Gryffin… "11\" Holly phoenix… Stag
## 2 2 Ronald Bilius Weasley Gryffin… "12\" Ash unicorn tai… Jack Russell …
## 3 3 Hermione Jean Granger Gryffin… "10¾\" vine wood dra… Otter
## 4 4 Albus Percival Wulfric … Gryffin… "15\" Elder Thestral … Phoenix
## 5 5 Rubeus Hagrid Gryffin… "16\" Oak unknown co… None
## 6 6 Neville Longbottom Gryffin… "13\" Cherry unicorn … Non-corporeal
## 7 7 Fred Weasley Gryffin… "Unknown" Unknown
## 8 8 George Weasley Gryffin… "Unknown" Unknown
## 9 9 Ginevra (Ginny) Molly W… Gryffin… "Unknown" Horse
## 10 10 Dean Thomas Gryffin… "Unknown" Unknown
## # … with 87 more rows
left_join(hp_wiz, hp_names, by = "id")
## # A tibble: 97 x 5
## id house wand patronus name
## <int> <chr> <chr> <chr> <chr>
## 1 1 Gryffin… "11\" Holly phoenix … Stag Harry James Potter
## 2 2 Gryffin… "12\" Ash unicorn tail… Jack Russell … Ronald Bilius Weasley
## 3 3 Gryffin… "10¾\" vine wood drag… Otter Hermione Jean Granger
## 4 4 Gryffin… "15\" Elder Thestral t… Phoenix Albus Percival Wulfric…
## 5 5 Gryffin… "16\" Oak unknown cor… None Rubeus Hagrid
## 6 6 Gryffin… "13\" Cherry unicorn h… Non-corporeal Neville Longbottom
## 7 7 Gryffin… "Unknown" Unknown Fred Weasley
## 8 8 Gryffin… "Unknown" Unknown George Weasley
## 9 9 Gryffin… "Unknown" Horse Ginevra (Ginny) Molly …
## 10 10 Gryffin… "Unknown" Unknown Dean Thomas
## # … with 87 more rows
hp_names
und hp_wiz
über die Spalte id
, sodass alle Zeilen aus hp_names
erhalten bleiben und das Ergebnis die Spalten beider Data Frames enthält. Fehlende Werte sollen als NA
im Ergebnis erscheinen. Es gibt hier verschiedene Lösungswege.right_join(hp_wiz, hp_names, by = "id")
## # A tibble: 140 x 5
## id house wand patronus name
## <int> <chr> <chr> <chr> <chr>
## 1 1 Gryffin… "11\" Holly phoenix … Stag Harry James Potter
## 2 2 Gryffin… "12\" Ash unicorn tail… Jack Russell … Ronald Bilius Weasley
## 3 3 Gryffin… "10¾\" vine wood drag… Otter Hermione Jean Granger
## 4 4 Gryffin… "15\" Elder Thestral t… Phoenix Albus Percival Wulfric…
## 5 5 Gryffin… "16\" Oak unknown cor… None Rubeus Hagrid
## 6 6 Gryffin… "13\" Cherry unicorn h… Non-corporeal Neville Longbottom
## 7 7 Gryffin… "Unknown" Unknown Fred Weasley
## 8 8 Gryffin… "Unknown" Unknown George Weasley
## 9 9 Gryffin… "Unknown" Horse Ginevra (Ginny) Molly …
## 10 10 Gryffin… "Unknown" Unknown Dean Thomas
## # … with 130 more rows
left_join(hp_names, hp_wiz, by = "id")
## # A tibble: 140 x 5
## id name house wand patronus
## <int> <chr> <chr> <chr> <chr>
## 1 1 Harry James Potter Gryffin… "11\" Holly phoenix… Stag
## 2 2 Ronald Bilius Weasley Gryffin… "12\" Ash unicorn tai… Jack Russell …
## 3 3 Hermione Jean Granger Gryffin… "10¾\" vine wood dra… Otter
## 4 4 Albus Percival Wulfric … Gryffin… "15\" Elder Thestral … Phoenix
## 5 5 Rubeus Hagrid Gryffin… "16\" Oak unknown co… None
## 6 6 Neville Longbottom Gryffin… "13\" Cherry unicorn … Non-corporeal
## 7 7 Fred Weasley Gryffin… "Unknown" Unknown
## 8 8 George Weasley Gryffin… "Unknown" Unknown
## 9 9 Ginevra (Ginny) Molly W… Gryffin… "Unknown" Horse
## 10 10 Dean Thomas Gryffin… "Unknown" Unknown
## # … with 130 more rows
full_join(hp_names, hp_wiz, by = "id")
## # A tibble: 140 x 5
## id name house wand patronus
## <int> <chr> <chr> <chr> <chr>
## 1 1 Harry James Potter Gryffin… "11\" Holly phoenix… Stag
## 2 2 Ronald Bilius Weasley Gryffin… "12\" Ash unicorn tai… Jack Russell …
## 3 3 Hermione Jean Granger Gryffin… "10¾\" vine wood dra… Otter
## 4 4 Albus Percival Wulfric … Gryffin… "15\" Elder Thestral … Phoenix
## 5 5 Rubeus Hagrid Gryffin… "16\" Oak unknown co… None
## 6 6 Neville Longbottom Gryffin… "13\" Cherry unicorn … Non-corporeal
## 7 7 Fred Weasley Gryffin… "Unknown" Unknown
## 8 8 George Weasley Gryffin… "Unknown" Unknown
## 9 9 Ginevra (Ginny) Molly W… Gryffin… "Unknown" Horse
## 10 10 Dean Thomas Gryffin… "Unknown" Unknown
## # … with 130 more rows
hp_names
und hp_looks
über die Spalte id
, sodass alle Beobachtungen und alle Spalten aus beiden Data Frames erhalten bleiben und die Spalten notfalls mit NA
gefüllt werden. Hier gibt es nur eine Lösung.full_join(hp_names, hp_looks, by = "id")
## # A tibble: 145 x 4
## id name hairColour eyeColour
## <int> <chr> <chr> <chr>
## 1 1 Harry James Potter Black Bright gre…
## 2 2 Ronald Bilius Weasley Red Blue
## 3 3 Hermione Jean Granger Brown Brown
## 4 4 Albus Percival Wulfric Brian Dumble… Silver| formerly aubu… Blue
## 5 5 Rubeus Hagrid Black Black
## 6 6 Neville Longbottom Blond <NA>
## 7 7 Fred Weasley Red Brown
## 8 8 George Weasley Red Brown
## 9 9 Ginevra (Ginny) Molly Weasley Red Bright bro…
## 10 10 Dean Thomas Black Brown
## # … with 135 more rows
id
heraus, für welche Beobachtungen in hp_looks
es keinen Match in hp_names
gibt. Hier gibt es nur eine Lösung.anti_join(hp_looks, hp_names, by = "id")
## # A tibble: 5 x 3
## id hairColour eyeColour
## <int> <chr> <chr>
## 1 141 blonde blue
## 2 142 reddish green
## 3 143 dark brown brown
## 4 144 black grey
## 5 145 ash blonde ice-blue
id
heraus, für welche Beobachtungen in hp_names
es keinen Match in hp_looks
gibt. Hier gibt es nur eine Lösung.anti_join(hp_names, hp_looks, by = "id")
## # A tibble: 8 x 2
## id name
## <int> <chr>
## 1 60 Rodolphus Lestrange
## 2 61 Millicent Bulstrode
## 3 62 Graham Montague
## 4 63 Bloody Baron
## 5 64 Marcus Flint
## 6 65 Penelope Clearwater
## 7 66 Roger Davies
## 8 67 Marcus Belby
hp_names
und hp_looks
über die Spalte id
, sodass alle Beobachtungen und alle Spalten aus beiden Data Frames erhalten bleiben, für die es einen Match in beiden Data Frames gibt (keine neu erzeugten NA
-Werte im Ergebnis). Hier gibt es nur eine Lösung.inner_join(hp_names, hp_looks, by = "id")
## # A tibble: 132 x 4
## id name hairColour eyeColour
## <int> <chr> <chr> <chr>
## 1 1 Harry James Potter Black Bright gre…
## 2 2 Ronald Bilius Weasley Red Blue
## 3 3 Hermione Jean Granger Brown Brown
## 4 4 Albus Percival Wulfric Brian Dumble… Silver| formerly aubu… Blue
## 5 5 Rubeus Hagrid Black Black
## 6 6 Neville Longbottom Blond <NA>
## 7 7 Fred Weasley Red Brown
## 8 8 George Weasley Red Brown
## 9 9 Ginevra (Ginny) Molly Weasley Red Bright bro…
## 10 10 Dean Thomas Black Brown
## # … with 122 more rows
id
heraus, für welche Personen in hp_names
es Messwerte in hp_measures
gibt. Hier gibt es nur eine Lösung.semi_join(hp_names, hp_measures, by = "id")
## # A tibble: 18 x 2
## id name
## <int> <chr>
## 1 1 Harry James Potter
## 2 2 Ronald Bilius Weasley
## 3 3 Hermione Jean Granger
## 4 4 Albus Percival Wulfric Brian Dumbledore
## 5 5 Rubeus Hagrid
## 6 6 Neville Longbottom
## 7 7 Fred Weasley
## 8 8 George Weasley
## 9 14 Sirius Black
## 10 30 Minerva McGonagall
## 11 35 Luna Lovegood
## 12 37 Filius Flitwick
## 13 38 Sybill Patricia Trelawney
## 14 46 Severus Snape
## 15 47 Draco Malfoy
## 16 50 Bellatrix Lestrange
## 17 51 Dolores Jane Umbridge
## 18 139 Dobby
ggplot2
Bei allen folgenden Plots dürfen Sie gerne mit den ggplot2
Spezifikationen spielen: Verändern Sie die Farben, Punkt-Shapes, Linientypen, Schriftgröße, Achsenbeschriftungen…
rating
. Auf der x-Achse soll das Rating angezeigt werden. Trennen Sie Panels nach Familiarität Fam
in Zeilen und Sprache Lang
in Spalten.ggplot(rating) +
aes(x = Rating) +
geom_density() +
facet_grid(Fam~Lang)
preasp
mit einem Boxplot den Einfluss von Artikulationsstelle cplace
auf die Verschlussdauer clodur
. Farbkodieren Sie die Boxplots nach Artikulationsstelle und erstellen Sie verschiedene Panels für die Variable Region. Schreiben Sie unter Ihrem Code Ihre Einschätzung zu der Fragestellung als Kommentar auf.ggplot(preasp) +
aes(x = cplace, y = clodur, fill = cplace) +
facet_wrap(~region) +
geom_boxplot()
# Ihre Einschätzung:
# Die Verschlussdauer ist am kürzesten in kk und am längsten in tt.
# Die Regionen unterscheiden sich diesbezüglich kaum.
RT
im Data Frame vcv
mit einer Balkenbreite von 75. Stellen Sie die drei Vokale in getrennten Panels dar.ggplot(vcv) +
aes(x = RT) +
facet_wrap(~Vowel) +
geom_histogram(color = "white", binwidth = 75)
billboard
für die folgenden Künstler artist
: “No Doubt”, “Spears, Britney”, “TLC”, “Aguilera, Christina”, “Backstreet Boys, The”, “Pink”, “Destiny’s Child”. Auf der y-Achse soll das Ranking und auf der x-Achse die Kalenderwoche aufgetragen werden – dazu müssen Sie die Spalten rank
und week
mittels pivoting erstellen. Nutzen Sie außerdem die Funktion factor()
innerhalb von mutate()
, um die Werte in der Spalte week
in einen Faktor mit den Levels 1 bis 32 umzuwandeln. Die Linien sollen nach dem Künstler farbkodiert werden. Da es pro Künstler zum Teil mehrere Songs in den Charts gibt, müssen Sie den aesthetic mappings noch group = track
hinzufügen.%>%
billboard filter(artist %in% c("No Doubt", "Spears, Britney", "TLC", "Aguilera, Christina",
"Backstreet Boys, The", "Pink", "Destiny's Child")) %>%
pivot_longer(cols = starts_with("wk"),
names_to = "week",
values_to = "rank",
names_prefix = "wk",
values_drop_na = TRUE) %>%
mutate(week = factor(week, levels = 1:32)) %>%
ggplot() +
aes(x = week, y = rank, col = artist, group = track) +
geom_line()
vdata
. Wählen Sie zuerst nur die Zeilen aus dem Data Frame aus, wo der Vokal V
entweder “A” oder “I” oder “U” ist. F2 gehört auf die x- und F1 auf die y-Achse. Farbkodieren Sie die Abbildung nach Vokal und erstellen Sie verschiedene Panels für die einzelnen Versuchspersonen Subj
. Sorgen Sie zuletzt dafür, dass die Achsen jeweils umgedreht werden, also von hohen zu niedrigen Werten; nutzen Sie dafür die folgenden zwei Funktionen: scale_x_reverse()
und scale_y_reverse()
.%>%
vdata filter(V %in% c("A", "I", "U")) %>%
ggplot() +
aes(x = F2, y = F1, col = V) +
facet_wrap(~Subj) +
scale_x_reverse() +
scale_y_reverse() +
geom_point()
hp...
Data Frames, um sich ein paar magische Plots auszudenken!<- inner_join(hp_names, hp_measures, by = "id") %>%
hp left_join(hp_looks, by = "id") %>%
left_join(hp_meta, by = "id") %>%
left_join(hp_wiz, by = "id")
%>%
hp filter(year != "2016") %>%
ggplot() +
aes(x = year, y = f0, col = name) +
geom_line(size = 1.2)
## Warning: Removed 4 row(s) containing missing values (geom_path).
%>%
hp mutate(year = factor(year, levels = c(1991:1997, 2016))) %>%
filter(!is.na(f0)) %>%
ggplot() +
aes(x = year, y = f0, group = name) +
geom_line(size = 1.2) +
facet_wrap(~name)
%>%
hp filter(!is.na(eyeColour) & !is.na(house)) %>%
ggplot() +
aes(x = house, fill = eyeColour) +
geom_bar(position = "fill")
%>%
hp filter(!is.na(house) & !is.na(f0)) %>%
ggplot() +
aes(y = f0, fill = house) +
geom_boxplot() +
facet_wrap(~name)
%>%
hp filter(!is.na(house) & !is.na(f0)) %>%
ggplot() +
aes(y = f0, fill = gender) +
geom_boxplot()