Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- training <- read.csv("~/Desktop/training.csv")
- library(shiny)
- library(tidyverse)
- # Define UI for application that draws a histogram
- ui <- shinyUI(fluidPage(
- titlePanel("Gráficas:"),
- # Sidebar with a slider input for Variables
- sidebarLayout(
- sidebarPanel(
- selectInput(inputId = "y",
- label = "y",
- choices = "Sales",
- selected = "Sales"
- ),
- selectInput(inputId = "x",
- label = "Variable",
- choices = c( "Products Bought" = "ProdBought",
- "Numero de casas" = "NumCasas"
- ),
- selected = "ProdBought")
- ),
- # Show a plot of the generated distribution
- mainPanel(
- plotOutput(outputId = "BarPlot")
- )
- )
- ))
- server <- shinyServer(function(input, output) {
- # generate plot
- output$BarPlot <- renderPlot({
- training %>%
- group_by(input$x, Sales) %>%
- count() -> conteos
- ggplot(data = conteos, aes(x = input$x, y = n, fill = Sales)) +
- geom_col()
- })
- })
- # Run the application
- shinyApp(ui = ui, server = server)
Add Comment
Please, Sign In to add comment