Reputation: 2380
What is the easiest way to change the font color of a single row dataframe with tableOutput. Specifically, how to change the "7" under "Right" to green.
library(shiny)
shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel(
fluidRow(
tableOutput("view")
)
),
mainPanel(
))),
server = function(input, output, session){
correct <- reactiveValues(num = 7)
wrong <- reactiveValues(num = 4)
skipped <- reactiveValues(num = 9)
togo = 80
output$view <- renderTable(tibble(
Right = correct$num,
Wrong = wrong$num,
Skipped = skipped$num,
ToGo = togo
), spacing = "xs")
}
)
Upvotes: 1
Views: 2050
Reputation: 6325
It is better to use DT
in this case that comes with renderDataTable
for better formatting.
library(shiny)
library(tidyverse)
library(DT)
shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel(
fluidRow(
column(8,dataTableOutput("view"))
)
),
mainPanel(
))),
server = function(input, output, session){
correct <- reactiveValues(num = 7)
wrong <- reactiveValues(num = 4)
skipped <- reactiveValues(num = 9)
togo = 80
output$view <- renderDataTable(datatable(tibble(
Right = correct$num,
Wrong = wrong$num,
Skipped = skipped$num,
ToGo = togo
)) %>% formatStyle("Right",color=styleEqual(7, "red")) )
}
)
library(shiny)
library(tidyverse)
library(DT)
shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel(
fluidRow(
column(8,dataTableOutput("view"))
)
),
mainPanel(
))),
server = function(input, output, session){
correct <- reactiveValues(num = 7)
wrong <- reactiveValues(num = 4)
skipped <- reactiveValues(num = 9)
togo = 80
output$view <- renderDataTable(datatable(tibble(
Right = correct$num,
Wrong = wrong$num,
Skipped = skipped$num,
ToGo = togo
), options = list(dom = 't')) %>% formatStyle("Right",color=styleEqual(7, "red")) )
}
)
Upvotes: 1