Skip to content

Instantly share code, notes, and snippets.

@vnijs
Created June 8, 2015 21:44
Show Gist options
  • Save vnijs/86a9d9ac7010123f4dac to your computer and use it in GitHub Desktop.
Save vnijs/86a9d9ac7010123f4dac to your computer and use it in GitHub Desktop.
Cold call list
---
output: html_document
runtime: shiny
---
``` {r, echo=FALSE}
library(knitr)
suppressMessages(library(dplyr))
rady_class <- c("heroins")
```
## Class `r rady_class`
Image source: <http://www.huffingtonpost.com/2014/06/09/fairytale-mugshots_n_5475538.html>
```{r, echo=FALSE}
student_info <- function(rady_class) {
info <- data.frame(first_name = c("Alice","Red"), last_name = c("Carroll","Hood"))
info$pref_name <- info$first_name
info$id <- paste0(info$pref_name, ".", info$last_name)
images <- paste0(rady_class, "/", info$id, ".jpg")
info$images <- paste0("<img src='", images, "' title='", info$pref_name," ", info$last_name,"' style='height:60px'>")
stud_list <- kable(info, format = "markdown")
list("stud_df" = info, "stud_list" = stud_list)
}
actionButton("cc_call_em", "Cold call")
rnd_students <- function(rady_class) {
ret <- student_info(rady_class)$stud_df
ret$rnd_number <- runif(nrow(ret), min = 0, max = 1)
ret %>% arrange(desc(rnd_number))
}
DT::renderDataTable({
if(input$cc_call_em == 0) return()
rnd_students(rady_class) %>% slice(1) %>%
DT::datatable(rownames = FALSE, style = "bootstrap", escape = FALSE,
options = list(
paging = FALSE,
searching = FALSE,
searchable = FALSE,
columnDefs = list(list(className = 'dt-center', targets = "_all")),
autoWidth = TRUE,
processing = FALSE
)
)
})
```
<details open>
<summary>List</summary>
`r student_info(rady_class)$stud_list`
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment