get_baseline: Find a baseline value

View source: R/change_from_baseline.R

get_baselineR Documentation

Find a baseline value

Description

Find a baseline value

Usage

get_baseline(col, .filter, ..., fun.summ = mean_)

Arguments

col

An unquoted variable name

.filter

An unquoted R logical expression (evaluates to TRUE or FALSE). Pass TRUE to select all records for summarization.

...

Comma separated, unquoted, additional grouping columns

fun.summ

An unquoted function name to use to summarise multiple baseline values per group

Details

get_baseline can be used inside a mutate or summarise call, and therefore inside the get mapped value functions (e.g., getDV). It finds the rows that satisfy the criteria in the .filter argument, then applies fun.summ (a summary function) to those rows. In this way, multiple values can be used for a baseline value.

Value

Returns a vector of selected baseline values

Examples

library(dplyr)
library(PMDatR)
Theoph %>% mutate(conc.bl = get_baseline(conc, Time>0 & Time<1, Subject, fun.summ=mean_))
Theoph %>% mutate(conc=set_units(conc,"mg/ml"),
  conc.bl = get_baseline(conc, Time>0 & Time<1, Subject, fun.summ=mean_)) %>% as_data_frame

qPharmetra/PMDatR documentation built on April 7, 2024, 5:42 p.m.