Calculate the Average Number of Active Needles for Each Row in a Data Frame
Source:R/add_average_active_needles.R
add_average_active_needles.Rd
This function takes a data frame that contains columns starting with "fraction" and containing "active_needles". It calculates the average number of active needles for each row, rounds it, and adds this as a new column to the data frame. If the average is NaN, it is replaced with NA.
Value
A data frame with an additional column `average_nr_active_needles` that contains the rounded average number of active needles for each row. If the average was NaN, it is replaced with 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)
} # }