Skip to contents

Add average labels to a plot.

Usage

acid_geom_label_average(data, col, fun = c("mean", "median"), digits = 0L, ...)

Arguments

data

data.frame. Data frame, containing plot data.

col

character(1). Column name.

fun

character(1). Function name to use for average calculation. Currently supports mean or median.

digits

integer(1). Number of significant digits to use. Defaults to rounded.

...

Additional arguments, passed to acid_geom_label().

Value

Layer/ggproto.

Details

For example, col can be nGene. Median or mean values are always calculated per sample (sampleName).

Note

Updated 2021-06-29.

Examples

data <- data.frame(
    "sampleName" = rep(c("sample1", "sample2"), times = 4L),
    "counts" = seq_len(8L)
)
geom <- acid_geom_label_average(
    data = data,
    col = "counts",
    fun = "mean"
)
print(geom)
#> mapping: label = ~.data[["roundedAverage"]] 
#> geom_label: parse = FALSE, label.padding = 0.2, label.r = 0.15, label.size = NA, size.unit = mm, na.rm = FALSE
#> stat_identity: na.rm = FALSE
#> position_identity