View source: R/normalizations.R
norm_logmeans | R Documentation |
Normalize vowel formant measurements a log-means normalization procedure as described in Barreda & Nearey (2018). This function is intended to be used within a tidyverse pipeline.
norm_logmeans(
.df,
.formant_cols,
.speaker_col,
.vowel_col,
.return = "data",
i_know_more_than_you = FALSE
)
.df |
The data frame containing the formant measurements you want to normalize. Formant data must be log transformed! See example code below. |
.formant_cols |
The (unquoted) name(s) of the column containing the formant measurements. |
.speaker_col |
The (unquoted) name of the column containing the unique identifiers per speaker. |
.vowel_col |
The (unquoted) name of the column containing the unique identifiers per vowel |
.return |
A string. By default, |
i_know_more_than_you |
Logical. The function won't work if you've got data that doesn't look like log10-transformed formant data. If you want to force the function to run anyway, set this to 'TRUE'. |
The data should not be grouped beforehand (e.g. with group_by
).
The data must be numeric, and there cannot be any NA
s.
The original dataframe with new columns containing the normalized measurements. These new columns have "_norm" appended to the column names.
Thanks to Santiago Barreda for providing most of the code for this function.
Barreda, Santiago, and Terrance M. Nearey. 2018. "A Regression Approach to Vowel Normalization for Missing and Unbalanced Data." The Journal of the Acoustical Society of America 144(1): 500–520. https://doi.org/10.1121/1.5047742.
library(tidyverse)
idaho <- joeysvowels::idahoans
# Basic usage. Note that the data has to be log10-transformed.
idaho %>%
mutate(F1_log = log10(F1), F2_log = log10(F2)) %>%
norm_logmeans(.formant_cols = c(F1_log, F2_log),
.speaker_col = speaker,
.vowel_col = vowel) %>%
head()
# Return the speaker paramters instead.
idaho %>%
mutate(F1_log = log10(F1), F2_log = log10(F2)) %>%
norm_logmeans(.formant_cols = c(F1_log, F2_log),
.speaker_col = speaker,
.vowel_col = vowel,
.return = "params") %>%
head()
# If you forget to log-transform the data, it'll throw an error.
idaho %>%
norm_logmeans(.formant_cols = c(F1, F2),
.speaker_col = speaker,
.vowel_col = vowel)
# But you can force the function to run on non-transformed data if you're sure you know what you're doing.
idaho %>%
norm_logmeans(.formant_cols = c(F1, F2),
.speaker_col = speaker,
.vowel_col = vowel,
i_know_more_than_you = TRUE) %>%
head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.