View source: R/stat-pop-etho.R
| stat_pop_etho | R Documentation |
This function displays the temporal (time on the x axis) trend of variable of interest, on the y axis as a line with confidence interval as a shaded area.
stat_pop_etho( mapping = NULL, data = NULL, geom = "smooth", position = "identity", ..., method = mean_se, method.args = list(), show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data, either as a
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to |
method |
function used to compute the aggregate and confidence intervals.
It should return ( |
method.args |
List of additional arguments passed on to the modelling
function defined by |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A ggplot layer.
The relevant rethomic tutorial section
ggetho to generate a plot object
stat_tile_etho to show variable of interest as colour intensity
stat_ld_annotations to show light and dark phases on the plot
ggplot2::stat_smooth to understand how to change the type of confidence interval, line colour and so forth
Other layers:
geom_peak(),
stat_bar_tile_etho(),
stat_ld_annotations()
library(behavr)
metadata <- data.frame(id = sprintf("toy_experiment | %02d", 1:4),
age=c(1, 5, 10, 20),
condition=c("A", "B"))
dt <- toy_activity_data(metadata, 3)
# We build a plot object
pl <- ggetho(dt, aes(y = asleep))
# A standard plot of the whole population:
pl + stat_pop_etho()
# We can also split by condition, and display the two population on different facets:
pl + stat_pop_etho() + facet_grid(condition ~ .)
## Not run:
# Instead, we can use different colour for separate conditions:
pl <- ggetho(dt, aes(y = asleep, colour = condition))
pl + stat_pop_etho()
# Sometimes, we also have numeric condition (e.g. age)
pl <- ggetho(dt, aes(y = asleep, colour = age))
pl + stat_pop_etho()
# We could want to aggregate several days of data to one circadian day (i.e. time wrapping)
# here, we also plot the invert of moving (!moving)
pl <- ggetho(dt, aes(y = !moving), time_wrap = hours(24))
pl + stat_pop_etho()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.