Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- title: "shajni"
- runtime: shiny
- #output: html_document
- ---
- ```{r echo = FALSE}
- library(shiny)
- selectInput("n_breaks", label = "Number of bins:",
- choices = c(10, 20, 35, 50), selected = 20)
- sliderInput("bw_adjust", label = "Bandwidth adjustment:",
- min = 0.2, max = 2, value = 1, step = 0.2)
- ```
- ```{r echo = FALSE}
- renderPlot({
- hist(faithful$eruptions, probability = TRUE,
- breaks = as.numeric(input$n_breaks),
- xlab = "Duration (minutes)",
- main = "Geyser eruption duration")
- dens <- density(faithful$eruptions, adjust = input$bw_adjust)
- lines(dens, col = "blue")
- })
- ```
- ```{r}
- library(miniUI)
- library(ggplot2)
- ggbrush <- function(data, xvar, yvar) {
- ui <- miniPage(
- gadgetTitleBar("Drag to select points"),
- miniContentPanel(
- # The brush="brush" argument means we can listen for
- # brush events on the plot using input$brush.
- plotOutput("plot", height = "100%", brush = "brush")
- )
- )
- server <- function(input, output, session) {
- # Render the plot
- output$plot <- renderPlot({
- # Plot the data with x/y vars indicated by the caller.
- ggplot(data, aes_string(xvar, yvar)) + geom_point()
- })
- # Handle the Done button being pressed.
- observeEvent(input$done, {
- # Return the brushed points. See ?shiny::brushedPoints.
- stopApp(brushedPoints(data, input$brush))
- })
- }
- runGadget(ui, server)
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement