Skip to contents

Calculate responses differences from baseline for each subject

Usage

calculateDiffsFromBase(
  data,
  respCol = getEctdColName("Response"),
  idCol = getEctdColName("Subject"),
  timeCol = getEctdColName("Time"),
  replicateCol = getEctdColName("Replicate"),
  baseDef = paste(timeCol, "<= 0"),
  tolerance = 1e-05,
  removeBaseline = TRUE
)

Arguments

data

Data frame

respCol

Response column names (given by getEctdColName by default)

idCol

Subject column names (given by getEctdColName by default)

timeCol

Time column names (given by getEctdColName by default)

replicateCol

Replicate column names (given by getEctdColName by default)

baseDef

Defintion of what "baseline data" is for each subject (default is "Time <= 0")

tolerance

Any eventual response values whose absolute

removeBaseline

Logical: Should we remove the baseline data once "differences from baseline" have been calculated?

Value

A data frame, where responses have had each subjects baseline response subtracted

Details

The inputs are checked, and the function ensures that respCol, idCol and timeCol are all variables in the dataset (data). The baseDef code is applied to the data in order to create a logical vector highlighting observations classed as being "baseline" values.

If any subjects do not have "baseline" data, a warning is generated and the original data is returned.

For each subject, the baseline response is calculated as the mean response within the baseline period identified. Within subject, the baseline response is subtracted from each response value. If removeBaseline is TRUE, the baseline data itself is removed from the dataset

Author

Mike K Smith mstoolkit@googlemail.com