# Load in example dataset d
data(d)
# Create labels for group and race
groups = c("Control","Treatment")
races = c("White","Black","Mexican American","Other")
# Compare mean BMI in control group vs. treatment group
meanstable1 = tabmeans(x=d$group,y=d$bmi,xlevels=groups,yname="BMI")
# Compare mean BMI by race and omit sample size
meanstable2 = tabmeans(x=d$race,y=d$bmi,xlevels=races,yname="BMI",n=FALSE)
# Create single table comparing mean BMI and mean age in control vs. treatment group
meanstable3 = rbind(tabmeans(x=d$group,y=d$bmi,xlevels=groups,yname="BMI"),
tabmeans(x=d$group,y=d$age,xlevels=groups,yname="Age"))
# Click on meanstable1, meanstable2, and meanstable3 in the Workspace tab of RStudio
# to see the tables that could be copied and pasted into a report or manuscript.
Run the code above in your browser using DataLab