ggperio: Prepare a ggplot object to represent periodogram data

View source: R/ggperio.R

ggperioR Documentation

Prepare a ggplot object to represent periodogram data

Description

This function summarises periodogram data (containing periodograms of multiple individual), to show period on the x axis, and power (or equivalent) on the y axis.

Usage

ggperio(data, mapping = aes(x = period, y = power), ...)

Arguments

data

behavr::behavr table containing the data and metadata

mapping

default list of aesthetic mappings to use for plot

...

additional arguments to be passed to ggplot2::ggplot()

Value

An initial ggplot object that can be further edited.

References

See Also

  • ggetho to plot time series

  • geom_peak to draw peaks on a periodogram

  • zeitgebr::periodogram to compute periodograms in a first place

  • ggspectro to visualise spectrograms

Examples


require(zeitgebr)
# We make toy data
metadata <- data.table(id = sprintf("toy_experiment|%02d", 1:40),
                       region_id = 1:40,
                       condition = c("A", "B"),
                       sex = c("M", "M", "F", "F"))
dt <- toy_activity_data(metadata, seed = 107)
# We shift period of the group "A" by 0.01
dt[, t := ifelse(xmv(condition) == "A", t, t * 1.01)]
# We  compute a periodogram for each individual
per_dt <- periodogram(moving, dt, FUN = chi_sq_periodogram)

# Then we display them as an average
out <- ggperio(per_dt, aes(y = power, colour = condition))
out +  stat_pop_etho()

out <- ggperio(per_dt, aes(y = power - signif_threshold, colour = condition))
out +  stat_pop_etho()
out <- ggperio(per_dt, aes(y = power - signif_threshold, colour = condition))
out +  stat_pop_etho() + facet_wrap( ~ id, labeller = id_labeller)


ggetho documentation built on Nov. 24, 2022, 5:09 p.m.