Lab 14 (4/23/15)

Part 0. Course evaluations

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

Part 1. Conditional formatting

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

  1. Rows alternating grey/white shading
  2. Proper p-value formatting
  3. Red text color indicating significant p-values
  4. Rounded odds ratio and confidence interval columns to 2 decimal places
# 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

Part 2. Shiny applications

  1. Take a look at an example from the shiny gallery: http://shiny.rstudio.com/gallery/faithful.html
  2. What function is needed in your ui.R file to add checkboxes?
  3. Modify your shiny function to have checkboxes instead of dropdown menu for month. Hints:
  • You will need one checkbox for each month
  • It might be helpful to first print the output corresponding to the checkboxes to determine how to handle the data when multiple boxes are selected.