---
title: "Iris Dataset Plot"
author: "Katia Bulekova"
format: dashboard
server: shiny
---

```{r}
#| context: setup
library(ggplot2)
library(shiny)
library(MASS)
```

# {.sidebar}



```{r}
selectInput('x', 'X', names(iris[1:4]), selected="Sepal.Length") 
selectInput('y', 'Y', names(iris)[1:4], selected="Sepal.Width")
selectInput('species', 'Species', unique(iris$Species), selected = "setosa")
```


# Plot

```{r}
plotOutput('plot')
```

# Data

```{r}
tableOutput('data')
```

```{r}
#| context: server

dataset <- reactive({
  iris[iris$Species==input$species,]
})
 
output$plot <- renderPlot({

  p <- ggplot(
    dataset(), 
    aes_string(x=input$x, y=input$y)) + geom_point()
  
  
  p
  
})

output$data <- renderTable({
  dataset()
})
```