# How to export TextGrid and Formant data from Praat: http://recordit.co/ybhGxsf99a | |
# Make sure to setwd() to where annotations.csv and formants.csv are located | |
library(dplyr) | |
library(readr) | |
left_join( | |
read_csv("annotations.csv") %>% mutate(join_col = "temp"), | |
read_csv("formants.csv") %>% mutate(join_col = "temp") | |
) %>% | |
select(-join_col) %>% | |
filter(tmin >= `time(s)`, `time(s)` <= tmax) %>% | |
group_by(Vowel = text) %>% | |
summarise( | |
F1_average = mean(`F1(Hz)`), | |
F2_average = mean(`F2(Hz)`), | |
) |
Also: SO EXCITED THIS IS SO MUCH FUN I'M HAVING A GREAT TIME
Oh, and you'll have to load ggplot2 for that.
Here's the full script with my edits:
library(dplyr)
library(readr)
library(ggplot2)
left_join(
read_csv("annotations.csv") %>% mutate(join_col = "temp"),
read_csv("formants.csv") %>% mutate(join_col = "temp")
) %>%
select(-join_col) %>%
filter(tmin >= time(s)
, time(s)
<= tmax) %>%
group_by(Vowel = text) %>%
summarise(
F1_average = mean(F1(Hz)
),
F2_average = mean(F2(Hz)
),
) -> Vowel_chart
ggplot(Vowel_chart, aes(x=F1_average, y=F2_average, label = Vowel )) + geom_point() + geom_text(aes(label=Vowel),hjust=0, vjust=0) -> Vowel_chart_plot
plot<- Vowel_chart_plot
pdf("My_first_vowel_plot_in_r.pdf", width=5, height=5)
plot
dev.off()
_
/(|
( :
__\ \ _____
(____) `|
(____)| |
(____).__|
(___)__.|_____
SSt
ggplot(Vowel_table, aes(x=F1_average, y=F2_average, label = Vowel )) + geom_point() + geom_text(aes(label=Vowel),hjust=-1, vjust=-1) + scale_y_reverse() + scale_x_reverse() -> Vowel_chart_plot
plot(Vowel_chart_plot)
@HedvigS — also should have noted F2 (associated with tongue frontness/backness) should be on the x-axis (another reversal!)
ggplot(Vowel_table, aes(x=F2_average, y=F1_average, label = Vowel )) + geom_point() + geom_text(aes(label=Vowel),hjust=-1, vjust=-1) + scale_y_reverse() + scale_x_reverse() -> Vowel_chart_plot plot(Vowel_chart_plot)
I'd suggest adding this from line 17
-> Vowel_chart
ggplot(Vowel_chart, aes(x=F1_average, y=F2_average, label = Vowel )) + geom_point() + geom_text(aes(label=Vowel),hjust=0, vjust=0)