plot_prop_by_level: Statified Proportion Plot with Confidence Intervals

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Statified Proportion Plot with Confidence Intervals

Usage

1
2
plot_prop_by_level(dat, factor.var1, prop.var, alpha = 0.05,
  factor.var2 = NULL, ylab = "Proportion")

Arguments

dat

a data frame of patient characteristics from a study.

factor.var1

string indicating the first factor variable to stratify by (what will be on the x-axis)

prop.var

string indicating the outcome variable to calculate the proportion of. Must be binary or logical

alpha

the confidence level to use for the confidence interval construction. by default it uses 0.05 => 95% confidence intervals.

factor.var2

string indicating the second factor variable to stratify by (what will be designated by color), default is NULL which ignores this argument.

Details

This function produic

Value

a ggplot of the probability of the outcome stratified by factor.var1 and (optionally) factor.var2

Author(s)

Jesse D. Raffa

See Also

ggplot

Examples

1
2
3
4
5
set.seed(1)
require(ggplot2); require(dplyr)
N <- 100;
dataf <- data.frame(outcome=sample(c(0,1),N,replace=TRUE),age=c(runif(N-1,0,100),NA),sex=as.factor(sample(c(0,1,NA),N,replace=TRUE)),cholesterol=rnorm(N,100,30),rx=as.factor(sample(c(0,1),N,replace=TRUE)))
plot_prop_by_level(dataf,"rx","outcome",factor.var2="sex")

jraffa/MIMICbook documentation built on May 19, 2019, 11:51 p.m.