Skip to content

Instantly share code, notes, and snippets.

@xiaodaigh
Created September 20, 2013 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaodaigh/6632557 to your computer and use it in GitHub Desktop.
Save xiaodaigh/6632557 to your computer and use it in GitHub Desktop.
Beginner help on input and plotting
library(shiny)
#tu<-read.csv(file="tu.csv", header = TRUE, sep = ",")
#attach(tu)
tu <- data.frame(id=rnorm(1000),size=rnorm(1000),months=rnorm(1000))
shinyServer(function(input, output) {
it<- reactive({
print(input$tu)
switch(input$tu,
"id" = tu$id,
"size" = tu$size,
"months" = tu$months)
})
output$distplot<- renderPlot({ hist(it())
})
})
shinyUI(pageWithSidebar(
headerPanel("statistics"),
sidebarPanel(
selectInput("tu", "Variable:", list("id"="id","size"="size","months"="months")))
, mainPanel(
plotOutput("distplot")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment