## Creating a table summary

table_summ <- data_intermediate %>%
    group_by(cohort, visit) %>%
    summarise(n = n(),
              n_missing = sum(is.na(value)),
              min = min(value, na.rm = TRUE),
              Q1 = quantile(value, probs = c(0.25), na.rm = TRUE),
              median = median(value, na.rm = TRUE),
              Q3 = quantile(value, probs = c(0.75), na.rm = TRUE),
              max = max(value, na.rm = TRUE),
              mean = mean(value, na.rm = TRUE),
              std = sd(value, na.rm = TRUE)) %>%
    ungroup() %>%
    mutate(n = format(n, big.mark = ','),
           n_missing = format(n_missing, big.mark = ','),
           min = round(min, digits = 1),
           Q1 = round(Q1, digits = 1),
           median = round(median, digits = 1),
           Q3 = round(Q3, digits = 1),
           max = round(max, digits = 1),
           mean = round(mean, digits = 1),
           std = round(std, digits = 1))



kable(table_summ) %>%
  kable_styling()


## Creating box plots

ggplot(data_intermediate, aes(x = factor(visit), y = value, fill = factor(visit))) +
  geom_boxplot() +
  theme_bw() +
  labs(
    title = glue('Boxplots of {current_cat}'),
    subtitle = current_cohort,
    fill = 'Visit') +
  #scale_fill_brewer(palette = 'Set1') +
  scale_fill_manual(values = combined_color_palette) + ## Color palette that accommodates more values
  #theme(axis.text.x = element_blank()) +
  ylab(units) +
  xlab('Visit')


Try the psHarmonize package in your browser

Any scripts or data that you put into this service are public.

psHarmonize documentation built on April 4, 2025, 1:50 a.m.