Skip to content

Instantly share code, notes, and snippets.

Created November 10, 2013 12:26
Show Gist options
  • Save anonymous/7397648 to your computer and use it in GitHub Desktop.
Save anonymous/7397648 to your computer and use it in GitHub Desktop.
# 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
)
}
)
# 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