Permalink
Browse files

Added Geyeser demo apps and data flow slides for presentation.

  • Loading branch information...
1 parent 4e3b1d1 commit 4fbdd38375c0e19696828a99fec39ef8b35c6ea0 @trestletech committed Feb 8, 2013
View
@@ -0,0 +1,55 @@
+log <- function(text, file="log.txt"){
+ log <- file(file, "at")
+ writeLines(text, con=log)
+ print(text)
+ close(log)
+}
+
+shinyServer(function(input, output) {
+
+ log("Server init.")
+
+
+
+
+
+ output$main_plot <- reactivePlot(function() {
+ log("Getting dataset...")
+
+ if (input$dataset == "Geyeser"){
+ dataset <- (faithful$eruptions)
+ }
+ if (input$dataset == "NYC Wind"){
+ dataset <- (airquality$Wind)
+ }
+
+ log("Setting data name...")
+
+ if (input$dataset == "Geyeser"){
+ dataName <- ("Eruption Duration (min)")
+ }
+ if (input$dataset == "NYC Wind"){
+ dataName <- ("Wind Speed (mph)")
+ }
+
+
+ log("Plotting hist...")
+
+ hist(dataset,
+ probability = TRUE,
+ breaks = as.numeric(input$n_breaks),
+ xlab = dataName,
+ main = "Histogram of Data")
+
+ if (input$individual_obs) {
+ rug(dataset)
+ }
+
+ if (input$density) {
+ dens <- density(dataset,
+ adjust = input$bw_adjust)
+ lines(dens, col = "blue")
+ }
+
+ })
+})
View
@@ -0,0 +1,30 @@
+shinyUI(bootstrapPage(
+
+ selectInput(inputId = "dataset",
+ label="Dataset to visualize:",
+ choices=c("Geyeser", "NYC Wind"),
+ selected = "Geyeser"),
+
+ selectInput(inputId = "n_breaks",
+ label = "Number of bins in histogram (approximate):",
+ choices = c(10, 20, 35, 50),
+ selected = 20),
+
+ checkboxInput(inputId = "individual_obs",
+ label = strong("Show individual observations"),
+ value = FALSE),
+
+ checkboxInput(inputId = "density",
+ label = strong("Show density estimate"),
+ value = FALSE),
+
+ plotOutput(outputId = "main_plot", height = "300px"),
+
+ # Display this only if the density is shown
+ conditionalPanel(condition = "input.density == true",
+ sliderInput(inputId = "bw_adjust",
+ label = "Bandwidth adjustment:",
+ min = 0.2, max = 2, value = 1, step = 0.2)
+ )
+
+))
@@ -0,0 +1,54 @@
+log <- function(text, file="log.txt"){
+ log <- file(file, "at")
+ writeLines(text, con=log)
+ print(text)
+ close(log)
+}
+
+shinyServer(function(input, output) {
+
+ log("Server init.")
+
+ getData <- reactive(function(){
+ log("Getting dataset...")
+
+ if (input$dataset == "Geyeser"){
+ return(faithful$eruptions)
+ }
+ if (input$dataset == "NYC Wind"){
+ return(airquality$Wind)
+ }
+ })
+
+ dataName <- reactive(function(){
+ log("Setting data name...")
+
+ if (input$dataset == "Geyeser"){
+ return("Eruption Duration (min)")
+ }
+ if (input$dataset == "NYC Wind"){
+ return("Wind Speed (mph)")
+ }
+ })
+
+ output$main_plot <- reactivePlot(function() {
+ log("Plotting hist...")
+
+ hist(getData(),
+ probability = TRUE,
+ breaks = as.numeric(input$n_breaks),
+ xlab = dataName(),
+ main = "Histogram of Data")
+
+ if (input$individual_obs) {
+ rug(getData())
+ }
+
+ if (input$density) {
+ dens <- density(getData(),
+ adjust = input$bw_adjust)
+ lines(dens, col = "blue")
+ }
+
+ })
+})
View
@@ -0,0 +1,30 @@
+shinyUI(bootstrapPage(
+
+ selectInput(inputId = "dataset",
+ label="Dataset to visualize:",
+ choices=c("Geyeser", "NYC Wind"),
+ selected = "Geyeser"),
+
+ selectInput(inputId = "n_breaks",
+ label = "Number of bins in histogram (approximate):",
+ choices = c(10, 20, 35, 50),
+ selected = 20),
+
+ checkboxInput(inputId = "individual_obs",
+ label = strong("Show individual observations"),
+ value = FALSE),
+
+ checkboxInput(inputId = "density",
+ label = strong("Show density estimate"),
+ value = FALSE),
+
+ plotOutput(outputId = "main_plot", height = "300px"),
+
+ # Display this only if the density is shown
+ conditionalPanel(condition = "input.density == true",
+ sliderInput(inputId = "bw_adjust",
+ label = "Bandwidth adjustment:",
+ min = 0.2, max = 2, value = 1, step = 0.2)
+ )
+
+))
Binary file not shown.
@@ -0,0 +1,12 @@
+shinyServer(function(input, output) {
+
+ output$main_plot <- reactivePlot(function() {
+
+ hist(faithful$eruptions,
+ probability = TRUE,
+ breaks = as.numeric(input$n_breaks),
+ xlab = "Duration (minutes)",
+ main = "Geyser eruption duration")
+
+ })
+})
View
@@ -0,0 +1,10 @@
+shinyUI(bootstrapPage(
+
+ selectInput(inputId = "n_breaks",
+ label = "Number of bins in histogram (approximate):",
+ choices = c(10, 20, 35, 50),
+ selected = 20),
+
+ plotOutput(outputId = "main_plot", height = "300px")
+
+))

0 comments on commit 4fbdd38

Please sign in to comment.