Replaces the replicates of each condition by their mean and the standard error of the mean.
Usage
reduceReplicates(
data,
select = "condition",
datatrans = NULL,
keep = NULL,
weighted = FALSE
)
# S3 method for class 'data.frame'
reduceReplicates(
data,
select = "condition",
datatrans = NULL,
keep = NULL,
weighted = FALSE
)Arguments
- data
A data frame with the columns
name(observable),time,valueandcondition, plus any further columns that define conditions.- select
Names of the columns whose values, together with
name,timeandcondition, define a condition. Default"condition".- datatrans
Character, an expression in
xapplied tovaluebefore the reduction, for example"log(x)". DefaultNULL.- keep
Names of columns that are kept although their values differ within a condition; the first value is used. Default
NULL.- weighted
Logical. If
TRUE, mean and standard error are weighted by1 / sigma^2from the columnsigmaofdata. DefaultFALSE.
Value
A data frame with the columns
- time
Time of the measurement.
- value
Mean of the replicates.
- sigma
Standard error of the mean,
NAfor a single measurement.- n
Number of replicates.
- name
Observable.
- condition
The values of the
selectcolumns other thannameandtime, joined by"_".
followed by the kept columns.
Details
A column not in select is kept when it has the same value for all
replicates of every condition, otherwise it is dropped with a message.
Examples
data <- data.frame(name = "y", time = rep(c(0, 1, 2), each = 3),
value = c(1.0, 1.2, 0.9, 0.6, 0.5, 0.7, 0.3, 0.2, 0.25),
condition = "ctrl", replicate = rep(1:3, 3))
reduceReplicates(data)
#> Dropped columns: replicate
#> time value sigma n name condition
#> 1 0 1.033333 0.08819171 3 y ctrl
#> 4 1 0.600000 0.05773503 3 y ctrl
#> 7 2 0.250000 0.02886751 3 y ctrl