Created
November 10, 2013 12:26
-
-
Save anonymous/7397648 to your computer and use it in GitHub Desktop.
second version of shiny app on
https://groups.google.com/forum/#!topic/shiny-discuss/P74Ch8xHW_4
This file contains hidden or 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
# server.R | |
shinyServer( | |
function(input, output) { | |
# table of inputs | |
output$table.input <- renderTable( | |
{input$data} | |
, include.rownames = FALSE | |
, include.colnames = TRUE | |
, digits = 3 | |
, sanitize.text.function = function(x) x | |
) | |
# table of outputs | |
output$table.output <- renderTable( | |
{input$data^2} | |
, include.rownames = FALSE | |
, include.colnames = TRUE | |
, digits = 3 | |
, sanitize.text.function = function(x) x | |
) | |
} | |
) |
This file contains hidden or 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
# ui.R | |
library("shiny") | |
#library('devtools') | |
#install_github('shiny-incubator', 'rstudio') | |
library("shinyIncubator") | |
# initialize data with colnames | |
df <- data.frame(matrix(0, 1, 2)) | |
colnames(df) <- c("First Column","Second Column") | |
shinyUI( | |
pageWithSidebar( | |
headerPanel('Simple matrixInput example') | |
, | |
sidebarPanel( | |
# customize display settings | |
tags$head( | |
tags$style(type='text/css', "table.data { width: 200px; }" | |
, ".well {width: 80%; background-color: NULL; border: 0px solid rgb(255, 255, 255); box-shadow: 0px 0px 0px rgb(255, 255, 255) inset;}" | |
, ".data { background-color: rgb(255,255,255); }" | |
) | |
) | |
, | |
wellPanel( | |
h4("Input Table") | |
, | |
matrixInput(inputId = 'data', label = 'Add/Remove Rows', data = df) | |
, | |
helpText("This table accepts user input into each cell. The number of rows may be controlled by pressing the +/- buttons.") | |
) | |
) | |
, | |
mainPanel( | |
wellPanel( | |
wellPanel( | |
h4("Input Table") | |
, | |
tableOutput(outputId = 'table.input') | |
, | |
helpText("This table displays the input matrix in the side panel.") | |
) | |
, | |
wellPanel( | |
h4("Output Table") | |
, | |
tableOutput(outputId = 'table.output') | |
, | |
helpText("This table displays the matrix obtained by squaring all cells in the input matrix") | |
) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment