Applies a summary function to y along unique values of x. This is useful, say, for quickly plotting mean values of your dataset. Internally, type_summary() applies a thin wrapper around ave and then passes the result to type_lines for drawing.
Usage
type_summary(fun = mean, ...)
Arguments
fun
summarizing function. Should be compatible with ave. Defaults to mean.
…
Additional arguments are passed to the lines() function, ex: type=“p”, col=“pink”.
See Also
ave which performs the summarizing (averaging) behind the scenes.
Examples
library("tinyplot")# Plot the mean chick weight over timetinyplot(weight ~ Time, data = ChickWeight, type =type_summary())
# mean is the default function, so the above is equivalent totinyplot(weight ~ Time, data = ChickWeight, type =type_summary(mean))# Plot the median insteadtinyplot(weight ~ Time, data = ChickWeight, type =type_summary(median))
# Works with groups and/or facets tootinyplot(weight ~ Time | Diet, facet ="by", data = ChickWeight, type =type_summary())
# Custom/complex function exampletinyplot( weight ~ Time | Diet, facet ="by", data = ChickWeight,type =type_summary(function(y) quantile(y, probs =0.9)/max(y)))