I am trying to show icons in a datatable. When I try showing it inside a data table the icons show up as text. <i class="glyphicon glyphicon-ok"></i>
Do icons work with datatable.
library(shiny)
library(DT)
library(dplyr)
df <- data.frame(Channel = c("A", "B","C"),
Current = c(2000, 3000, 4000),
Modified = c(2500, 3500,3000),
New_Membership = c(500, 500,-1000),
stringsAsFactors = FALSE)
#### Module 1 renders the first table
tableMod <- function(input, output, session, modelRun,modelData,ratesData,budget){
gicon <- function(x) as.character(icon(x, lib = "glyphicon"))
output$x1 <- DT::renderDataTable({
isolate(
datatable(
modelData %>% mutate(myvar = Modified - Current) %>%
mutate(direction = ifelse(
Current < Modified,
as.character(gicon("ok")),
as.character(gicon("remove")))), selection = 'none', editable = TRUE
)
)
})
}
firstTableUI <- function(id) {
ns <- NS(id)
dataTableOutput(ns("x1"))
}
ui <- function(request) {
fluidPage(
firstTableUI("opfun"),
numericInput("budget_input", "Total Forecast", value = 2),
actionButton("opt_run", "Run") )
}
server <- function(input, output, session) {
callModule( tableMod,"opfun",
modelRun = reactive(input$opt_run),
modelData = df,
ratesData = rates,
budget = reactive(input$budget_input))
observeEvent(input$opt_run, {
cat('HJE')
})
}
shinyApp(ui, server, enableBookmarking = "url")