Skip to content

Instantly share code, notes, and snippets.

@annoporci
Created November 5, 2013 04:24
Show Gist options
  • Save annoporci/7313856 to your computer and use it in GitHub Desktop.
Save annoporci/7313856 to your computer and use it in GitHub Desktop.
# server.R
library("shiny")
shinyServer(
function(input, output) {
myFunction <- function(myinput)
{
# compute output
myoutput <- myinput*myinput
myoutput
}
# Show computed values
output$myResults <- renderTable(
{
r <- c("My Output:",myFunction(input$myinput))
myTable <- do.call(rbind, list(r))
myTable
}
, align = c("clc")
, include.rownames = FALSE
, include.colnames = FALSE
, sanitize.text.function = function(x) x
)#end renderTable
}#end function(input,output)
)#end shinyServer
# ui.R
library("shiny")
# Define UI for slider demo application
shinyUI(
pageWithSidebar(
# Title
headerPanel("Input-Output Shiny App")
,
# User Input in sidebar panel
sidebarPanel(
# customize display settings
tags$head(
tags$style(type='text/css', "input { width: 100px; }")# control numericInput box
,
tags$style(type='text/css', "select,textarea,.jslider,.well { font-size:50%; } ")# control font / ineffective
)
,
# user input
numericInput("myinput", "My Input:", 0)
)# end sidebarPanel
,
# Output in main panel
# See output$myResults in server.R
mainPanel(
tableOutput("myResults")
)# end mainPanel
)#end pageWithSidebar
)#end shinyUI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment