Created
November 6, 2012 06:51
-
-
Save wch/4023122 to your computer and use it in GitHub Desktop.
Scatter plot with model fit lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(shiny) | |
| shinyServer(function(input, output) { | |
| output$main_plot <- reactivePlot(function() { | |
| plot(x = faithful$eruptions, y = faithful$waiting, | |
| xlab = "Eruption duration (minutes)", | |
| ylab = "Waiting to next eruption (minutes)", | |
| main = "Eruptions of Old Faithful geyser") | |
| if (input$show_model == "Linear") { | |
| abline(lm(waiting ~ eruptions, data = faithful), col = "blue") | |
| } else if (input$show_model == "LOWESS") { | |
| lines(lowess(faithful$eruptions, faithful$waiting), col = "blue") | |
| } | |
| }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(shiny) | |
| shinyUI(bootstrapPage( | |
| selectInput(inputId = "show_model", | |
| label = "Show prediction from model:", | |
| choices = c("None", "Linear", "LOWESS")), | |
| plotOutput(outputId = "main_plot") | |
| )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment