Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. ---
  2. title: "shajni"
  3. runtime: shiny
  4. #output: html_document
  5. ---
  6.  
  7. ```{r echo = FALSE}
  8. library(shiny)
  9. selectInput("n_breaks", label = "Number of bins:",
  10. choices = c(10, 20, 35, 50), selected = 20)
  11.  
  12. sliderInput("bw_adjust", label = "Bandwidth adjustment:",
  13. min = 0.2, max = 2, value = 1, step = 0.2)
  14. ```
  15.  
  16.  
  17.  
  18. ```{r echo = FALSE}
  19. renderPlot({
  20. hist(faithful$eruptions, probability = TRUE,
  21. breaks = as.numeric(input$n_breaks),
  22. xlab = "Duration (minutes)",
  23. main = "Geyser eruption duration")
  24.  
  25. dens <- density(faithful$eruptions, adjust = input$bw_adjust)
  26. lines(dens, col = "blue")
  27. })
  28. ```
  29.  
  30. ```{r}
  31. library(miniUI)
  32. library(ggplot2)
  33.  
  34. ggbrush <- function(data, xvar, yvar) {
  35.  
  36. ui <- miniPage(
  37. gadgetTitleBar("Drag to select points"),
  38. miniContentPanel(
  39. # The brush="brush" argument means we can listen for
  40. # brush events on the plot using input$brush.
  41. plotOutput("plot", height = "100%", brush = "brush")
  42. )
  43. )
  44.  
  45. server <- function(input, output, session) {
  46.  
  47. # Render the plot
  48. output$plot <- renderPlot({
  49. # Plot the data with x/y vars indicated by the caller.
  50. ggplot(data, aes_string(xvar, yvar)) + geom_point()
  51. })
  52.  
  53. # Handle the Done button being pressed.
  54. observeEvent(input$done, {
  55. # Return the brushed points. See ?shiny::brushedPoints.
  56. stopApp(brushedPoints(data, input$brush))
  57. })
  58. }
  59.  
  60. runGadget(ui, server)
  61. }
  62. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement