View source: R/prev_visit_at_threshold.R
prev_visit_at_threshold | R Documentation |
This function determines which visits (if any) for each subject occur after that subject's C-peptide AUC has reached the detection limit. This function is intended to be used to filter out such visits, to prevent violations of the linearity assumption in the model fitting for slope estimation. For AUC values, it's assumed that the AUC has reached the detection limit when means the C-peptide levels for each timepoint in the MMTT or OGTT are at the detection limit; the AUC detection limit should be calculated as such. As input, the function takes a data frame of C-peptide values, with subject identifiers and a date or visit column on which to sort the visits. Note that visits will be sorted blindly, so character visit names (e.g. Day 1, Week 1, Month 2) should be used with EXTREME CAUTION! Numeric, date, or factor visit values are strongly preferred.
prev_visit_at_threshold(
cpeptide_auc_data, threshold,
identifier_column = "subject", sort_column = "visit",
auc_column = "auc")
cpeptide_auc_data |
data frame containing the C-peptide data. Should contain a unique subject identifer, a column for sorting visits, and the C-peptide AUC data. Each row should be a single visit. |
threshold |
numeric, the threshold C-peptide AUC value. Values at or below this level will be treated as sub-threshold. |
identifier_column |
character or numeric, the column containing the subject identifiers. By default it uses "subject". |
sort_column |
character or numeric, the column on which each subject's visits should be sorted. This should be either numeric, date, or character that will be sorted consistently by dplyr::arrange(). If set to NULL, rows for each subject will be assumed to be in the desired order. By default it uses "visit". |
auc_column |
character or numeric, the column containing the C-peptide AUC values. By default it uses "auc". |
a logical vector, with each element corresponding to a row of the input data frame; contains TRUE if the subject already had C-peptide AUC at or below the threshold at prior visits, and FALSE otherwise.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.