install.packages(
c(
"phonTools",
"ngramr"
)
)
Day 5
in-class
Setup
Recap
ggplot2
summary(sneak_past)
Year Phrase Frequency Corpus
Min. :1800 sneaked:221 Min. :0.000e+00 en-2019:442
1st Qu.:1855 snuck :221 1st Qu.:1.845e-09
Median :1910 Median :1.474e-07
Mean :1910 Mean :2.030e-07
3rd Qu.:1965 3rd Qu.:2.639e-07
Max. :2020 Max. :1.654e-06
Anatomy of a ggplot
library(ggplot2)
ggplot(
data = sneak_past,
aes(
x = Year,
y = Frequency
)
) +
geom_line(
aes(linetype = Phrase)
) +
geom_point(
aes(
shape = Phrase
)
)
pb52 |>
ggplot(
aes(
x = f0,
y = f1
)
) +
#geom_point() +
stat_smooth()
install.packages("ggthemes")
The following package(s) will be installed:
- ggthemes [5.1.0]
These packages will be installed into "~/work/Lin611-2024.github.io/Lin611-2024.github.io/renv/library/macos/R-4.4/aarch64-apple-darwin20".
# Installing packages --------------------------------------------------------
- Installing ggthemes ... OK [linked from cache]
Successfully installed 1 package in 6 milliseconds.
pb52 |>
ggplot(
aes(
x = f2,
y = f1,
color = vowel
)
) +
geom_text(
aes(label = vowel)
) +
scale_color_ptol() +
scale_x_reverse() +
scale_y_reverse() +
labs(
x = "F2 (front-back)",
y = "F1 (high-low)",
color = "VOWEL",
title = "Peterson & Barney (1952)",
subtitle = "These are vowels",
caption = "Source: {phonTools}"
) +
guides(
color = "none"
)+
facet_wrap(~type) +
theme_bw()+
theme(
aspect.ratio = 1
) -> vowel_plot
vowel_plot
ggsave(
filename = "vowel_plot.png",
plot = vowel_plot,
width = 15,
height = 5
)
Reuse
CC-BY 4.0
Citation
BibTeX citation:
@online{fruehwald2024,
author = {Fruehwald, Josef},
title = {Day 5},
date = {2024-09-11},
url = {https://lin611-2024.github.io/notes/in-class/2024-09-11_day5.html},
langid = {en}
}
For attribution, please cite this work as:
Fruehwald, Josef. 2024. “Day 5.” September 11, 2024. https://lin611-2024.github.io/notes/in-class/2024-09-11_day5.html.