Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created May 25, 2013 17:14
Show Gist options
  • Save ramnathv/5649899 to your computer and use it in GitHub Desktop.
Save ramnathv/5649899 to your computer and use it in GitHub Desktop.
Shiny Tables using hwriter
require(shiny)
require(hwriter)
dat <- read.csv(textConnection("homeTeam, homeScore, awayTeam, awayScore
Boston, 3, NY Rangers, 4
Chicago, 0, Detroit, 2
San Jose, 0, Los Angeles, 3"), header = TRUE)
shinyServer(function(input, output){
output$mytable <- renderText({
homeClasses = with(dat, ifelse(homeScore > awayScore, 'winner', 'loser'))
awayClasses = with(dat, ifelse(awayScore > homeScore, 'winner', 'loser'))
myClasses = cbind(homeClasses, "", awayClasses, "")
hwrite(dat, class=myClasses,
table.class = 'table table-striped table-bordered table-condensed')
})
})
require(shiny)
shinyUI(pageWithSidebar(
headerPanel('Table with hwriter'),
sidebarPanel(
),
mainPanel(
tags$style(type = 'text/css',
"td.loser {color: red;}
td.winner{color: green;font-weight:bolder}"
),
htmlOutput('mytable')
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment