SHARE
TWEET

Untitled

a guest May 26th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---
  2. title: "Untitled"
  3. author: "Emily Riederer"
  4. date: "5/15/2019"
  5. output: html_document
  6. ---
  7.  
  8. ```{r}
  9. # dummy data
  10. data <- data.frame(
  11.   METRIC = paste('var', 1:10),
  12.   VAL = runif(10),
  13.   stringsAsFactors = FALSE
  14. )
  15. ```
  16.  
  17. ```{r results = 'asis'}
  18. # automatically generate <style> block of css for each tab
  19. tab_number <- 1:nrow(data)
  20. tab_color <- ifelse(data$VAL > 0.75, 'green', ifelse(data$VAL > 0.25, 'yellow', 'red'))
  21.  
  22. css <- sprintf(".nav-pills>li:nth-child(%d){background:%s;}", tab_number, tab_color)
  23. css <- paste(css, collapse = "\n")
  24. css <- paste("<style>", css, "</style>")
  25. cat(css)
  26. ```
  27.  
  28. # section {.tabset .tabset-pills}
  29.  
  30. ```{r, results='asis'}
  31. # dynamically generate code for each chunk
  32. vars <- data$METRIC
  33. val <- data$VAL
  34. out <- paste("##", vars, "<br>\n", "The value is ", val, "<br>\n<br>\n\n")
  35. invisible(lapply(out, cat))
  36. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top