Skip to content

Commit aa24212

Browse files
authored
Merge pull request #498 from mko-mini/master
Zagubiona wyjsciowka
2 parents ff2aeae + ba211dd commit aa24212

File tree

1 file changed

+45
-0
lines changed
  • Wyjsciowki/W5/gr2/KosmiderMichal

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
library(shiny)
2+
library(ggplot2)
3+
library(dplyr)
4+
5+
ui <- fluidPage(
6+
titlePanel("Chicks"),
7+
8+
sidebarLayout(
9+
sidebarPanel(
10+
checkboxGroupInput(inputId = "chosen_diet",
11+
label = "Select diet:",
12+
choices = unique(ChickWeight$Diet)),
13+
sliderInput(inputId = "range_start", label = "Start przedziału czasu",
14+
min = min(ChickWeight$Time), max = max(ChickWeight$Time),
15+
value = min(ChickWeight$Time)),
16+
sliderInput(inputId = "range_end", label = "Koniec przedziału czasu",
17+
min = min(ChickWeight$Time), max = max(ChickWeight$Time),
18+
value = max(ChickWeight$Time))
19+
),
20+
21+
mainPanel(
22+
h2("Scatterplot"),
23+
plotOutput("plot", height = 600)
24+
)
25+
)
26+
)
27+
28+
server <- function(input, output) {
29+
chicks <- reactive({
30+
r <- filter(ChickWeight, between(Time, input[["range_start"]], input[["range_end"]]))
31+
r$Diat <- factor(r$Diet)
32+
r
33+
})
34+
35+
output[["plot"]] <- renderPlot({
36+
chicks() %>%
37+
filter(Diet %in% input[["chosen_diet"]]) %>%
38+
ggplot(aes(group = Diet, x = Time, y = weight)) +
39+
geom_point(aes(col = Diet)) +
40+
stat_smooth(aes(col = Diet), se = FALSE) +
41+
theme(legend.position = 'none')
42+
})
43+
}
44+
45+
shinyApp(ui = ui, server = server)

0 commit comments

Comments
 (0)