/R/mod_table.R
https://github.com/JohnCoene/coronavirus · R · 56 lines · 32 code · 6 blank · 18 comment · 2 complexity · 7bc4bce5a3799173fc93c34a750a46f9 MD5 · raw file
- # Module UI
-
- #' @title mod_table_ui and mod_table_server
- #' @description A shiny Module.
- #'
- #' @param id shiny id
- #' @param input internal
- #' @param output internal
- #' @param session internal
- #'
- #' @rdname mod_table
- #'
- #' @keywords internal
- #' @export
- #' @importFrom shiny NS tagList
- mod_china_ui <- function(id, label){
- ns <- NS(id)
- f7Col(
- f7ExpandableCard(
- title = label,
- id = "china_card",
- subtitle = "Cases by provinces in China",
- uiOutput(ns("table"))
- )
- )
- }
-
- # Module Server
-
- #' @rdname mod_table
- #' @export
- #' @keywords internal
-
- mod_china_server <- function(input, output, session, df){
- ns <- session$ns
- output$table <- renderUI({
- df %>%
- dplyr::filter(date == max(date)) %>%
- dplyr::filter(country == "China") %>%
- dplyr::select(state, type, cases) %>%
- tidyr::pivot_wider(state, names_from = type, values_from = cases) %>%
- dplyr::arrange(-confirmed) %>%
- dplyr::mutate(
- confirmed = as.integer(confirmed),
- death = as.integer(death)
- ) %>%
- dplyr::select(
- Province = state,
- Confirmed = confirmed,
- Deaths = death
- ) %>%
- as_f7_table(card = TRUE)
- })
- }