## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup, eval = FALSE------------------------------------------------------
# install.packages("devtools")
# devtools::install_github("congzhang365/rhythm.metrics")

## ----import libraries, warning=F, message=FALSE-------------------------------
library(rhythm.metrics)
library(dplyr)
library(ggplot2)

## -----------------------------------------------------------------------------
df <- data.frame (cv_label  = c("consonant", "vowel", "consonant", "vowel",
                                "consonant", "vowel", "consonant", "vowel",
                                "consonant", "vowel", "consonant", "vowel",
                                "consonant", "vowel", "consonant", "vowel"),
                  utterance_id = c("utt_1", "utt_1", "utt_1", "utt_1",
                                   "utt_2", "utt_2", "utt_2", "utt_2",
                                   "utt_3", "utt_3", "utt_3", "utt_3",
                                   "utt_4", "utt_4", "utt_4", "utt_4"),
                  cv_duration = c(0.1, 0.8, 0.2, 0.5, 
                                  0.3, 0.3, 0.4, 0.7,
                                  0.3, 0.88, 0.5, 0.9, 
                                  0.3, 0.57, 0.4, 0.97),
                  utterance_duration = c(2.4, 2.4, 2.4, 2.4,
                                         2.7, 2.7, 2.7, 2.7,
                                         3.4, 3.4, 3.4, 3.4,
                                         1.8, 1.8, 1.8, 1.8))
df

## -----------------------------------------------------------------------------
delta_cv(df, cv_label, utterance_id, cv_duration)

## -----------------------------------------------------------------------------
plot_delta_cv(df, cv_label, utterance_id, cv_duration)

## -----------------------------------------------------------------------------
varco_cv(df, cv_label, utterance_id, cv_duration)

## -----------------------------------------------------------------------------
plot_varco_cv(df, cv_label, utterance_id, cv_duration)

## -----------------------------------------------------------------------------
percentage_v(df, v_label = "vowel", utterance_id, cv_duration, utterance_duration)

## -----------------------------------------------------------------------------
plot_percentage_v(df, cv_label, label_name = "vowel", 
                  utterance_id, cv_duration, utterance_duration)

## -----------------------------------------------------------------------------
rpvi_c(df, cv_label, label_name = "consonant", utterance_id, cv_duration)

## -----------------------------------------------------------------------------
plot_rpvi(df, cv_label, label_name = "consonant", utterance_id, cv_duration)

## -----------------------------------------------------------------------------
npvi_v(df, cv_label, label_name = "vowel", utterance_id, cv_duration)

## -----------------------------------------------------------------------------
plot_npvi(df, cv_label, label_name = "vowel", utterance_id, cv_duration)

