Created
May 25, 2013 17:14
-
-
Save ramnathv/5649899 to your computer and use it in GitHub Desktop.
Shiny Tables using hwriter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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