Description Usage Arguments Details Value Author(s) See Also Examples
Statified OR Plot with Confidence Intervals
1 2 3 | plot_OR_by_level(dat, factor.var1, prop.var, alpha = 0.05,
factor.var2 = NULL, ylab = "Proportion", ref.group = 1,
include.ref.group.effect = TRUE)
|
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. |
This function produces a plot
a ggplot of the ORs of the outcome stratified by factor.var1 and (optionally) factor.var2.
Jesse D. Raffa
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),N,replace=TRUE)),cholesterol=rnorm(N,100,30),rx=as.factor(sample(c(0,1),N,replace=TRUE)))
plot_OR_by_level(dataf,"sex","outcome",factor.var2="rx")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.