Learn R Programming

tidynorm

The goal of {tidynorm} is to provide convenient and tidy functions to normalize vowel formant data.

Installation

You can install tidynorm like so

install.packages("tidynorm")

You can install the development version of tidynorm like so:

## if you need to install `remotes`
# install.packages("remotes")
remotes::install_github("jofrhwld/tidynorm")

Example

Vowel formant frequencies are heavily influenced by vocal tract length differences between speakers. Equivalent vowels between speakers can have dramatically different frequency locations.

library(tidynorm)
library(ggplot2)
options(
  ggplot2.discrete.colour = c(
    lapply(
      1:6,
      \(x) c(
        "#4477AA", "#EE6677", "#228833",
        "#CCBB44", "#66CCEE", "#AA3377"
      )[1:x]
    )
  ),
  ggplot2.discrete.fill = c(
    lapply(
      1:6,
      \(x) c(
        "#4477AA", "#EE6677", "#228833",
        "#CCBB44", "#66CCEE", "#AA3377"
      )[1:x]
    )
  )
)

theme_set(
  theme_minimal(
    base_size = 16
  )
)
ggplot(
  speaker_data,
  aes(
    F2, F1,
    color = speaker
  )
) +
  ggdensity::stat_hdr(
    probs = c(0.95, 0.8, 0.5),
    alpha = 1,
    fill = NA,
    linewidth = 1
  ) +
  scale_x_reverse() +
  scale_y_reverse() +
  coord_fixed() +
  labs(
    title = "unnormalized"
  )

The goal of {tidynorm} is to provide tidyverse-friendly and familiar functions that will allow you to quickly normalize vowel formant data. There are a number of built in functions based on conventional normalization methods.

speaker_data |>
  norm_nearey(
    F1:F3,
    .by = speaker,
    .names = "{.formant}_nearey"
  ) ->
speaker_normalized
#> Normalization info
#> • normalized with `tidynorm::norm_nearey()`
#> • normalized `F1`, `F2`, and `F3`
#> • normalized values in `F1_nearey`, `F2_nearey`, and `F3_nearey`
#> • grouped by `speaker`
#> • within formant: FALSE
#> • (.formant - mean(.formant, na.rm = T))/(1)
speaker_normalized |>
  ggplot(
    aes(
      F2_nearey, F1_nearey,
      color = speaker
    )
  ) +
  ggdensity::stat_hdr(
    probs = c(0.95, 0.8, 0.5),
    alpha = 1,
    fill = NA,
    linewidth = 1
  ) +
  scale_x_reverse() +
  scale_y_reverse() +
  coord_fixed() +
  labs(
    title = "Nearey Normalized"
  )

There is also a tidynorm::norm_generic() function to allow you to define your own bespoke normalization methods. For example, a “robust Nearey” normalization method using the median, instead of the mean, could be done like so.

speaker_rnearey <- speaker_data |>
  norm_generic(
    F1:F3,
    .by = speaker,
    .by_formant = FALSE,
    .pre_trans = log,
    .L = median(.formant, na.rm = T),
    .names = "{.formant}_rnearey"
  )
#> Normalization info
#> • normalized with `tidynorm::norm_generic()`
#> • normalized `F1`, `F2`, and `F3`
#> • normalized values in `F1_rnearey`, `F2_rnearey`, and `F3_rnearey`
#> • grouped by `speaker`
#> • within formant: FALSE
#> • (.formant - median(.formant, na.rm = T))/(1)
speaker_rnearey |>
  ggplot(
    aes(
      F2_rnearey, F1_rnearey,
      color = speaker
    )
  ) +
  ggdensity::stat_hdr(
    probs = c(0.95, 0.8, 0.5),
    alpha = 1,
    fill = NA,
    linewidth = 1
  ) +
  scale_x_reverse() +
  scale_y_reverse() +
  coord_fixed() +
  labs(
    title = "Robust Nearey Normalized"
  )

Copy Link

Version

Install

install.packages('tidynorm')

Monthly Downloads

133

Version

0.4.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Josef Fruehwald

Last Published

October 26th, 2025

Functions in tidynorm (0.4.0)

dct

Discrete Cosine Transform
bark_to_hz

Bark to Hz
check_norm

Check Normalization Procedures
idct

Inverse Discrete Cosine Transform
idct_accel

Inverse Discrete Cosine Transform Acceleration
mel_to_hz

Mel to Hz
idct_rate

Inverse Discrete Cosine Transform Rate
dct_basis

DCT Basis
norm_dct_wattfab

Watt and Fabricius DCT normalization
norm_dct_lobanov

Lobanov DCT Normalization
norm_generic

Generic Normalization Procedure
norm_dct_deltaF

Delta F DCT Normalization
norm_lobanov

Lobanov Normalize
norm_dct_generic

Generic Formant DCT Normalization Procedure
norm_dct_nearey

Nearey DCT Normalization
norm_deltaF

Delta F Normalize
norm_dct_barkz

Bark Difference DCT Normalization
norm_barkz

Bark Difference Normalize
norm_track_nearey

Nearey Track Normalization
norm_track_lobanov

Lobanov Track Normalization
norm_wattfab

Watt & Fabricius Normalize
norm_track_wattfab

Watt and Fabricius Track normalization
reframe_with_dct

Reframe with DCT
options

tidynorm Options
speaker_data

Speaker Data
speaker_tracks

Speaker Tracks
norm_track_deltaF

Delta F Track Normalization
norm_track_generic

Generic Formant Track Normalization Procedure
reframe_with_idct

Reframe with IDCT
reframe_with_dct_smooth

Reframe with DCT Smooth
norm_nearey

Nearey Normalize
norm_track_barkz

Bark Difference Track Normalization
tidynorm_options

Set tidynorm options
tidynorm-package

tidynorm: Tools for Tidy Vowel Normalization
hz_to_bark

Hz to Bark
hz_to_mel

Hz to Mel