This function calculates and adds maximum tumor dimension columns for MRI and GYN measurements to the given dataframe. It computes the maximum dimension across specified tumor columns without using row-wise operations for improved performance. Additionally, it replaces infinite values with NA in the newly calculated maximum dimension columns.
Value
A dataframe with additional columns for the maximum MRI tumor dimension (`mri_max_tumor_dimension`), the maximum GYN tumor dimension (`gyn_max_tumor_dimension`), and the overall maximum tumor dimension (`max_tumor_dimension`). Infinite values in these new columns are replaced with NA.
Examples
# Assuming `df` is your dataframe with MRI and GYN tumor dimension columns:
df <- data.frame(
mri_tumor_width_sta_d = c(2, Inf, 4),
mri_tumor_height_sta_d = c(3, 5, NA),
gyn_tumor_width_sta_d = c(NA, 6, 2),
gyn_tumor_thickness_sta_d = c(1, 2, 3)
)
df <- add_max_tumor_dimension(df)
print(df)
#> mri_tumor_width_sta_d mri_tumor_height_sta_d gyn_tumor_width_sta_d
#> 1 2 3 NA
#> 2 Inf 5 6
#> 3 4 NA 2
#> gyn_tumor_thickness_sta_d mri_max_tumor_dimension_sta_d
#> 1 1 3
#> 2 2 Inf
#> 3 3 4
#> gyn_max_tumor_dimension_sta_d max_tumor_dimension_sta_d
#> 1 1 3
#> 2 6 Inf
#> 3 3 4