#' Data viewer user interface
#'
#' @param id, character used to specify namespace, see \code{shiny::\link[shiny]{NS}}
#'
#' @return a \code{shiny::\link[shiny]{tagList}} containing UI elements
mod_dataviewer_ui <- function(id){
ns <- NS(id)
tagList(
DT::DTOutput(ns("table"))
)
}
#' Data viewer module server-side processing
#'
#' @param input,output,session standard \code{shiny} boilerplate
#' @param dataset data frame (reactive) used in scatterplots as produced by
#' the \code{brushedPoints} function in the scatterplot module
#'
#' @return reactive vector of row IDs corresponding to the current view in the
#' datatable widget.
mod_dataviewer_server <- function(input, output, session, dataset){
ns <- session$ns
cols_select <- c("Year_Built", "Year_Sold", "Sale_Price", "Sale_Condition", "Lot_Frontage", "House_Style",
"Lot_Shape", "Overall_Cond", "Overall_Qual")
output$table <- renderDT({
filter(dataset(), selected_) %>%
select(one_of(cols_select))
}, filter = 'top', selection = 'none')
}
## To be copied in the UI
# mod_dataviewer_ui("dataviewer_ui_1")
## To be copied in the server
# callModule(mod_dataviewer_server, "dataviewer_ui_1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.