Use a single N value

This commit is contained in:
2024-09-05 20:19:29 -04:00
parent e82b6c5e59
commit fa54503a5a

View File

@@ -196,7 +196,7 @@ calculate_summary_stats <- function(df, variables, group_vars = c("conc_num", "c
# z_max = ~ifelse(sd(., na.rm = TRUE) == 0 | all(is.na(.)), NA,
# (max(., na.rm = TRUE) - mean(., na.rm = TRUE)) / sd(., na.rm = TRUE)) # Z-score
), .names = "{.fn}_{.col}")) %>%
mutate(N = ~sum(!is.na(L))) # count of non-NA L values
mutate(N = sum(!is.na(L))) # count of non-NA L values
# Join the summary stats back to the original dataframe
df_with_stats <- left_join(df, summary_stats, by = group_vars)