Skip to content

Instantly share code, notes, and snippets.

@t-student
Last active October 14, 2015 05:56
Show Gist options
  • Save t-student/c75390211f4129ca703d to your computer and use it in GitHub Desktop.
Save t-student/c75390211f4129ca703d to your computer and use it in GitHub Desktop.
# Create a 2x2 table of means:
calcstuff <- function(x){
a <- mean(x)
b <- length(x)
paste(round(a,4), " (n=", b,")", sep = "")
}
with(df1, tapply(sbp, list(gender,age.level), calcstuff))
# age<40 age>=40
# Female "131.1082 (n=6)" "142.3465 (n=5)"
# Male "134.8499 (n=4)" "143.815 (n=9)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment