Please complete the evaluations for this course before preceding to the next section. Evaluations can be found at http://www.sph.emory.edu/rollins-life/evaluation/index.html
Download the OR_df.RData
file from week 12’s lab. First, convert the variable column to a character. Then, create an html table (using rmarkdown and knitr) with
# Load data
load("OR_df.RData")
OR_df[, 1] <- as.character(OR_df[, 1])
# define colors
black1 <- rep("color: #000000;", nrow(OR_df))
red1 <- "color: #FF0000;"
# define colors for pvalue column
col_pval <- black1
col_pval[which(OR_df[, 3] < 0.05)] <- red1
# define color matrix
cols2 <- matrix(rep(black1, 5), ncol = 5)
cols2[, 3] <- col_pval
# format p-values
OR_df[, 3] <- txtPval(OR_df[, 3])
# format other columns
OR_df[, -c(1, 3)] <- round(OR_df[, -c(1, 3)], 2)
# Add row shading
h1 <- htmlTable(OR_df, col.rgroup = c("white", "grey"), css.cell = cols2)
h1
Variable | OR | p-value | LB | UB | |
---|---|---|---|---|---|
1 | chol | 1.01 | 0.001 | 1 | 1.02 |
2 | hdl | 0.98 | 0.024 | 0.96 | 1 |
3 | age | 1.06 | < 0.0001 | 1.04 | 1.08 |
4 | weight | 1.01 | 0.005 | 1 | 1.02 |
5 | height | 1.01 | 0.77 | 0.93 | 1.1 |
ui.R
file to add checkboxes?