Skip to contents

Computes the average number of active needles across all fractions for each subject. Identifies columns containing fraction-specific active needle counts and calculates their mean value.

Usage

add_average_active_needles(df)

Arguments

df

A data frame containing columns with pattern "fraction_*_active_needles" that store the number of active needles for each treatment fraction

Value

The input data frame with an additional column `average_nr_active_needles` containing the rounded average. NaN values are converted to NA.

Examples

if (FALSE) { # \dontrun{
df <- data.frame(fraction_1_active_needles = c(1, 2, 3),
                 fraction_2_active_needles = c(3, 4, 5),
                 some_other_column = c('a', 'b', 'c'))
average_active_needles(df)
} # }