View source: R/change_from_baseline.R
get_baseline | R Documentation |
Find a baseline value
get_baseline(col, .filter, ..., fun.summ = mean_)
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 |
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.
Returns a vector of selected baseline values
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.