library(shiny) ui <- fluidPage( titlePanel("Autode läbisõit kütusekoguse kohta"), sliderInput("bins", "Tulpade arv:", min = 1, max = 20, value = 7), plotOutput("distPlot"), plotOutput("joonis2")) server <- function(input, output) { output$joonis2 <- renderPlot({ par(bg = "white") plot(mtcars$hp, mtcars$mpg, xlim=c(0, 300), ylim=c(5, 30), type="n") rect(0, 0, 300, 35, col="green", border = NA) points(mtcars$hp, mtcars$mpg, col=ifelse(mtcars$am==1, "red", "black")) }) output$distPlot <- renderPlot({ x <- mtcars$mpg bins <- seq(min(x), max(x), length.out = input$bins + 1) hist(x, breaks = bins, col = 'black', border = 'white', main="Läbisõitude histogramm", ylab="sagedus", xlab="Miile galloni kohta") }) } shinyApp(ui = ui, server = server)