| ggperio | R Documentation |
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.
ggperio(data, mapping = aes(x = period, y = power), ...)
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 |
The relevant rethomic tutorial section
ggetho to plot time series
geom_peak to draw peaks on a periodogram
zeitgebr::periodogram to compute periodograms in a first place
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.