Skip to contents

This function creates a boxplot to compare a variable between sexes and saves the plot to a specified directory.

Usage

compSex(var, estimate_df, plot_df, output_dir)

Arguments

var

A character string representing the variable to be plotted.

estimate_df

A data frame containing the estimates.

plot_df

A data frame containing the data for plotting.

output_dir

A character string representing the directory to save the plot.

Value

A ggplot2 plot saved to output_dir.

Examples

var <- "example_var"
estimate_df <- data.frame(
    var = rep("example_var", 6),
    sex = c("M", "F", "M", "F", "M", "F"),
    akp_effect = c(0.5, -0.6, 0.7, -0.8, 0.9, -1.0),
    p_adjust = c(0.01, 0.02, 0.03, 0.04, 0.05, 0.06)
)
plot_df <- data.frame(
    sex = c("M", "F", "M", "F", "M", "F"),
    example_var = c(1, 9, 6, 5, 4, 3)
)
output_dir <- tempdir()
compSex(var, estimate_df, plot_df, output_dir)