Learn R Programming

tern

[![Check

Copy Link

Version

Install

install.packages('tern')

Monthly Downloads

1,648

Version

0.9.8

License

Apache License 2.0

Issues

Pull Requests

Stars

Forks

Maintainer

Joe Zhu

Last Published

April 14th, 2025

Functions in tern (0.9.8)

aesi_label

Labels for adverse event baskets
afun_selected_stats

Get selected statistics names
abnormal

Count patients with abnormal range values
add_riskdiff

Split function to configure risk difference column
add_rowcounts

Layout-creating function to add row total counts
abnormal_by_baseline

Count patients with abnormal analysis range values by baseline status
afun_riskdiff

Analysis function to calculate risk difference column values
abnormal_by_worst_grade

Count patients by most extreme post-baseline toxicity grade per direction of abnormality
abnormal_by_marked

Count patients with marked laboratory abnormalities
abnormal_lab_worsen_by_baseline

Count patients with toxicity grades that have worsened from baseline by highest grade post-baseline
analyze_colvars_functions

Analyze functions in columns
append_varlabels

Add variable labels to top left corner in table
analyze_variables

Analyze variables
arrange_grobs

Arrange multiple grobs
assertions

Additional assertions to use with checkmate
as.rtable

Convert to rtable
analyze_functions

Analyze functions
analyze_vars_in_cols

Analyze numeric variables in columns
apply_auto_formatting

Apply automatic formatting
argument_convention

Standard arguments
combine_vectors

Element-wise combination of two vectors
combination_function

Class for CombinationFunction
combine_counts

Combine counts
combine_groups

Reference and treatment group combination
check_diff_prop_ci

Check proportion difference arguments
bins_percent_labels

Labels for bins in percent
check_same_n

Check element dimension
c_label_n_alt

Content row function to add alt_counts_df row total to labels
c_label_n

Content row function to add row total to labels
cfun_by_flag

Constructor for content functions given a data frame with flag input
compare_variables

Compare variables between groups
control_riskdiff

Control function for risk difference column
control_incidence_rate

Control function for incidence rate
control_coxreg

Control function for Cox regression
control_step

Control function for subgroup treatment effect pattern (STEP) calculations
control_logistic

Control function for logistic regression model fitting
control_lineplot_vars

Control function for g_lineplot()
control_analyze_vars

Control function for descriptive statistics
control_annot

Control functions for Kaplan-Meier plot annotation tables
control_coxph

Control function for Cox-PH model
count_patients_with_flags

Count the number of patients with particular flags
count_patients_with_event

Count the number of patients with a particular event
control_surv_time

Control function for survfit models for survival time
control_surv_timepoint

Control function for survfit models for patients' survival rate at time points
count_occurrences_by_grade

Count occurrences by grade
count_patients_events_in_cols

Count patient events in columns
count_values

Count specific values
count_occurrences

Count occurrences
count_missed_doses

Count number of patients with missed doses by thresholds
count_cumulative

Cumulative counts of numeric variable by thresholds
d_count_cumulative

Description of cumulative count
cox_regression_inter

Cox regression helper function for interactions
cut_quantile_bins

Cut numeric vector into empirical quantile bins
d_proportion

Description of the proportion summary
d_pkparam

Generate PK reference dataset
d_onco_rsp_label

Description of standard oncology response
d_proportion_diff

Description of method used for proportion comparison
cox_regression

Cox proportional hazards regression
d_count_abnormal_by_baseline

Description function for s_count_abnormal_by_baseline()
d_count_missed_doses

Description function that calculates labels for s_count_missed_doses()
decorate_grob_set

Decorate set of grobs and add page numbering
d_test_proportion_diff

Description of the difference test between two proportions
default_na_str

Default string replacement for NA values
default_stats_formats_labels

Get default statistical methods and their associated formats, labels, and indent modifiers
desctools_binom

Confidence intervals for a difference of binomials
day2month

Conversion of days to months
d_survival_subgroups_colvars

Labels for column variables in survival duration by subgroup table
d_rsp_subgroups_colvars

Labels for column variables in binary response by subgroup table
.is_equal_float

Utility function to check if a float value is equal to another float value
estimate_multinomial_rsp

Estimate proportions of each level of a variable
estimate_proportion

Proportion estimation
draw_grob

Draw grob
empty_vector_if_na

Return an empty numeric if all elements are NA.
df_explicit_na

Encode categorical missing values in a data frame
estimate_coef

Hazard ratio estimation in interactions
df2gg

Convert data.frame object to ggplot object
f_conf_level

Utility function to create label for confidence interval
f_pval

Utility function to create label for p-value
factor_utils

Factor utilities
explicit_na

Missing data
decorate_grob

Add titles, footnotes, page Number, and a bounding box to a grid grob
decorate_grob_factory

Update page number
ex_data

Simulated CDISC data for examples
extract_by_name

Extract elements by name
extract_rsp_subgroups

Prepare response data for population subgroups in data frames
extract_rsp_biomarkers

Prepare response data estimates for multiple biomarkers in a single data frame
extract_survival_subgroups

Prepare survival data for population subgroups in data frames
extreme_format

Format extreme values
fit_coxreg

Fitting functions for Cox proportional hazards regression
format_count_fraction_lt10

Format count and fraction with special case for count < 10
format_count_fraction_fixed_dp

Format count and percentage with fixed single decimal place
extract_survival_biomarkers

Prepare survival data estimates for multiple biomarkers in a single data frame
format_auto

Format automatically using data significant digits
fit_survival_step

Subgroup treatment effect pattern (STEP) fit for survival outcome
forest_viewport

Create a viewport tree for the forest plot
g_bland_altman

Bland-Altman plot
g_forest

Create a forest plot from an rtable
format_extreme_values

Format a single extreme value
format_extreme_values_ci

Format extreme values part of a confidence interval
formatting_functions

Formatting functions
format_xx

Format XX as a formatting function
format_count_fraction

Format count and fraction
format_fraction_threshold

Format fraction with lower threshold
fit_logistic

Fit for logistic regression
format_fraction_fixed_dp

Format fraction and percentage with fixed single decimal place
fit_rsp_step

Subgroup treatment effect pattern (STEP) fit for binary (response) outcome
format_fraction

Format fraction and percentage
g_ipp

Individual patient plots
g_km

Kaplan-Meier plot
format_sigfig

Format numeric values by significant figures
h_adsl_adlb_merge_using_worst_flag

Helper function for deriving analysis datasets for select laboratory tables
get_smooths

Smooth function with optional grouping
g_lineplot

Line plot with optional table
groups_list_to_df

Convert list of groups to a data frame
g_step

Create a STEP graph
get_covariates

Utility function to return a named list of covariate names
h_decompose_gg

ggplot decomposition
h_append_grade_groups

Helper function for s_count_occurrences_by_grade()
g_waterfall

Horizontal waterfall plot
h_count_cumulative

Helper function for s_count_cumulative()
h_format_row

Helper function to format the optional g_lineplot table
h_adlb_worsen

Helper function to prepare ADLB with worst labs
h_col_indices

Obtain column indices
h_adlb_abnormal_by_worst_grade

Helper function to prepare ADLB for count_abnormal_by_worst_grade()
h_cox_regression

Helper functions for Cox proportional hazards regression
h_data_plot

Helper function to tidy survival fit data
h_g_ipp

Helper function to create simple line plot over time
h_ggkm

Helper function to create a KM plot
h_ancova

Helper function to return results of a linear model
h_biomarkers_subgroups

Helper functions for tabulation of a single biomarker result
h_map_for_count_abnormal

Helper function to create a map data frame for trim_levels_to_map()
h_incidence_rate

Helper functions for incidence rate
h_km_layout

Helper function to prepare a KM layout
h_grob_median_surv

Helper function to create survival estimation grobs
h_grob_y_annot

Helper function to create grid object with y-axis annotation
h_grob_tbl_at_risk

Helper function to create patient-at-risk grobs
h_glm_count

Helper functions for Poisson models
h_logistic_regression

Helper functions for multivariate logistic regression
h_odds_ratio

Helper functions for odds ratio estimation
h_grob_coxph

Helper function to create Cox-PH grobs
h_stack_by_baskets

Helper function to create a new SMQ variable in ADAE by stacking SMQ and/or CQ records.
h_proportions

Helper functions for calculating proportion confidence intervals
h_response_biomarkers_subgroups

Helper functions for tabulating biomarker effects on binary response by subgroup
h_response_subgroups

Helper functions for tabulating binary response by subgroup
h_split_param

Split parameters
h_split_by_subgroups

Split data frame by subgroups
h_prop_diff

Helper functions to calculate proportion difference
h_prop_diff_test

Helper functions to test proportion differences
h_pkparam_sort

Sort pharmacokinetic data by PARAM variable
h_ppmeans

Function to return the estimated means using predicted probabilities
incidence_rate

Incidence rate estimation
h_step

Helper functions for subgroup treatment effect pattern (STEP) calculations
h_xticks

Helper function to calculate x-tick positions
imputation_rule

Apply 1/3 or 1/2 imputation rule to data
h_survival_biomarkers_subgroups

Helper functions for tabulating biomarker effects on survival by subgroup
labels_or_names

Labels or names of list elements
h_tbl_median_surv

Helper function for survival estimations
h_worsen_counter

Helper function to analyze patients for s_count_abnormal_lab_worsen_by_baseline()
h_tbl_coxph_pairwise

Helper function for generating a pairwise Cox-PH table
n_available

Number of available (non-missing entries) in a vector
h_survival_duration_subgroups

Helper functions for tabulating survival duration by subgroup
odds_ratio

Odds ratio estimation
month2day

Conversion of months to days
prop_diff

Proportion difference estimation
prop_diff_test

Difference test for two proportions
labels_use_control

Update labels according to control specifications
logistic_regression_cols

Logistic regression multivariate column layout function
logistic_summary_by_flag

Logistic regression summary table
make_names

Make names without dots
muffled_car_anova

Muffled car::Anova
response_biomarkers_subgroups

Tabulate biomarker effects on binary response by subgroup
reapply_varlabels

Reapply variable labels
rtables_access

Helper functions for accessing information from rtables
prune_occurrences

Occurrence table pruning
range_noinf

Re-implemented range() default S3 method for numerical objects
response_subgroups

Tabulate binary response by subgroup
rtable2gg

Convert rtable objects to ggplot objects
s_bland_altman

Bland-Altman analysis
s_cox_multivariate

Multivariate Cox model - summarized results
sas_na

Convert strings to NA
stat_mean_ci

Confidence interval for mean
strata_normal_quantile

Helper function for the estimation of stratified quantiles
study_arm

Indicate study arm variable in formula
stat_median_ci

Confidence interval for median
stat_propdiff_ci

Proportion difference and confidence interval
score_occurrences

Occurrence table sorting
split_cols_by_groups

Split columns by groups of levels
stack_grobs

Stack multiple grobs
stat_mean_pval

p-Value of the mean
split_text_grob

Split text according to available text width
summarize_glm_count

Summarize Poisson negative binomial regression
survival_biomarkers_subgroups

Tabulate biomarker effects on survival by subgroup
summarize_logistic

Multivariate logistic regression table
summarize_change

Summarize change from baseline values or absolute baseline values
summarize_ancova

Summarize analysis of covariance (ANCOVA) results
summarize_num_patients

Count number of patients
summarize_colvars

Summarize variables in columns
summarize_functions

Summarize functions
survival_coxph_pairwise

Analyze a pairwise Cox-PH model
summarize_patients_exposure_in_cols

Count number of patients and sum exposure across all patients in columns
tidy.step

Custom tidy method for STEP results
tidy.glm

Custom tidy method for binomial GLM results
to_n

Replicate entries of a vector if required
tidy_coxreg

Custom tidy methods for Cox regression
to_string_matrix

Convert table into matrix of strings
tern-package

tern Package
try_car_anova

tryCatch around car::Anova
survival_time

Survival time analysis
survival_timepoint

Survival time point analysis
survival_duration_subgroups

Tabulate survival duration by subgroup
update_weights_strat_wilson

Helper function for the estimation of weights for prop_strat_wilson()
univariate

Univariate formula special term
unlist_and_blank_na

Blank for missing input
util_handling_additional_fun_params

Utilities to handle extra arguments in analysis functions
utils_split_funs

Custom split functions