Spaces:
Runtime error
Runtime error
James Wade
commited on
Commit
·
f868e0a
1
Parent(s):
77a1cf9
add theme_bw(), explicit sidebar argument, github to cran for pkgs
Browse files- .gitignore +4 -0
- Dockerfile +3 -6
- app.R +24 -22
- shiny_on_hf.Rproj +13 -0
.gitignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.Rproj.user
|
2 |
+
.Rhistory
|
3 |
+
.RData
|
4 |
+
.Ruserdata
|
Dockerfile
CHANGED
@@ -5,12 +5,9 @@ WORKDIR /code
|
|
5 |
# Install stable packages from CRAN
|
6 |
RUN install2.r --error \
|
7 |
ggExtra \
|
8 |
-
shiny
|
9 |
-
|
10 |
-
|
11 |
-
RUN installGithub.r \
|
12 |
-
rstudio/bslib \
|
13 |
-
rstudio/httpuv
|
14 |
|
15 |
COPY . .
|
16 |
|
|
|
5 |
# Install stable packages from CRAN
|
6 |
RUN install2.r --error \
|
7 |
ggExtra \
|
8 |
+
shiny \
|
9 |
+
bslib \
|
10 |
+
httpuv
|
|
|
|
|
|
|
11 |
|
12 |
COPY . .
|
13 |
|
app.R
CHANGED
@@ -8,20 +8,20 @@ df <- readr::read_csv("penguins.csv")
|
|
8 |
df_num <- df |> select(where(is.numeric), -Year)
|
9 |
|
10 |
ui <- page_fillable(theme = bs_theme(bootswatch = "minty"),
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
)
|
26 |
|
27 |
server <- function(input, output, session) {
|
@@ -31,17 +31,19 @@ server <- function(input, output, session) {
|
|
31 |
})
|
32 |
|
33 |
output$scatter <- renderPlot({
|
34 |
-
p <- ggplot(subsetted(), aes(!!input$xvar, !!input$yvar)) +
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
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 |
-
|
45 |
}
|
46 |
|
47 |
p
|
|
|
8 |
df_num <- df |> select(where(is.numeric), -Year)
|
9 |
|
10 |
ui <- page_fillable(theme = bs_theme(bootswatch = "minty"),
|
11 |
+
layout_sidebar(fillable = TRUE,
|
12 |
+
sidebar = sidebar(
|
13 |
+
varSelectInput("xvar", "X variable", df_num, selected = "Bill Length (mm)"),
|
14 |
+
varSelectInput("yvar", "Y variable", df_num, selected = "Bill Depth (mm)"),
|
15 |
+
checkboxGroupInput("species", "Filter by species",
|
16 |
+
choices = unique(df$Species), selected = unique(df$Species)
|
17 |
+
),
|
18 |
+
hr(), # Add a horizontal rule
|
19 |
+
checkboxInput("by_species", "Show species", TRUE),
|
20 |
+
checkboxInput("show_margins", "Show marginal plots", TRUE),
|
21 |
+
checkboxInput("smooth", "Add smoother"),
|
22 |
+
),
|
23 |
+
plotOutput("scatter")
|
24 |
+
)
|
25 |
)
|
26 |
|
27 |
server <- function(input, output, session) {
|
|
|
31 |
})
|
32 |
|
33 |
output$scatter <- renderPlot({
|
34 |
+
p <- ggplot(subsetted(), aes(!!input$xvar, !!input$yvar)) +
|
35 |
+
theme_bw() +
|
36 |
+
list(
|
37 |
+
theme(legend.position = "bottom"),
|
38 |
+
if (input$by_species) aes(color=Species),
|
39 |
+
geom_point(),
|
40 |
+
if (input$smooth) geom_smooth()
|
41 |
+
)
|
42 |
+
|
43 |
if (input$show_margins) {
|
44 |
margin_type <- if (input$by_species) "density" else "histogram"
|
45 |
p <- p |> ggExtra::ggMarginal(type = margin_type, margins = "both",
|
46 |
+
size = 8, groupColour = input$by_species, groupFill = input$by_species)
|
47 |
}
|
48 |
|
49 |
p
|
shiny_on_hf.Rproj
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Version: 1.0
|
2 |
+
|
3 |
+
RestoreWorkspace: Default
|
4 |
+
SaveWorkspace: Default
|
5 |
+
AlwaysSaveHistory: Default
|
6 |
+
|
7 |
+
EnableCodeIndexing: Yes
|
8 |
+
UseSpacesForTab: Yes
|
9 |
+
NumSpacesForTab: 2
|
10 |
+
Encoding: UTF-8
|
11 |
+
|
12 |
+
RnwWeave: Sweave
|
13 |
+
LaTeX: pdfLaTeX
|