Skip to content

Instantly share code, notes, and snippets.

@annoporci
Created November 7, 2013 00:24
Show Gist options
  • Save annoporci/7346772 to your computer and use it in GitHub Desktop.
Save annoporci/7346772 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 <- renderText({
r <- myFunction(input$myinput)
c("My Output:","<br><br>",r)
})
}#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
sidebarPanel(
# customize display settings
tags$head(
tags$style(type='text/css', "input { width: 80%; }")# control numericInput box
)
,
# user input
numericInput("myinput", "My Input:", 0)
)# end sidebarPanel
,
# Output
mainPanel(
HTML('<style type="text/css">
.row-fluid { width: 50%; }
.well { background-color: #99CCFF; }
.shiny-html-output { font-size: 20px; line-height: 21px; }
</style>')
,
wellPanel(
# See output$myResults in server.R
tableOutput("myResults")
)#end wellPanel
)# end mainPanel
)#end pageWithSidebar
)#end shinyUI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment