Spaces:
Runtime error
Runtime error
Update app.R
Browse files
app.R
CHANGED
@@ -25,27 +25,17 @@ ui <- page_fillable(theme = bs_theme(bootswatch = "minty"),
|
|
25 |
)
|
26 |
|
27 |
server <- function(input, output, session) {
|
|
|
28 |
subsetted <- reactive({
|
29 |
req(input$species)
|
30 |
df |> filter(Species %in% input$species)
|
31 |
})
|
32 |
|
33 |
output$scatter <- renderPlot({
|
34 |
-
p <- ggplot(subsetted(), aes(
|
35 |
-
theme(legend.position = "bottom")
|
36 |
-
if (input$by_species) aes(color=Species),
|
37 |
-
geom_point(),
|
38 |
-
if (input$smooth) geom_smooth()
|
39 |
-
)
|
40 |
-
|
41 |
-
if (input$show_margins) {
|
42 |
-
margin_type <- if (input$by_species) "density" else "histogram"
|
43 |
-
p <- p |> ggExtra::ggMarginal(type = margin_type, margins = "both",
|
44 |
-
size = 8, groupColour = input$by_species, groupFill = input$by_species)
|
45 |
-
}
|
46 |
-
|
47 |
p
|
48 |
-
}
|
49 |
}
|
50 |
|
51 |
shinyApp(ui, server)
|
|
|
25 |
)
|
26 |
|
27 |
server <- function(input, output, session) {
|
28 |
+
|
29 |
subsetted <- reactive({
|
30 |
req(input$species)
|
31 |
df |> filter(Species %in% input$species)
|
32 |
})
|
33 |
|
34 |
output$scatter <- renderPlot({
|
35 |
+
p <- ggplot(subsetted(), aes(.data[[input$xvar]], .data[[input$yvar]])) +
|
36 |
+
theme(legend.position = "bottom")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
p
|
38 |
+
})
|
39 |
}
|
40 |
|
41 |
shinyApp(ui, server)
|