Spaces:
Runtime error
Runtime error
so it begins :nest_with_eggs:
Browse files- Dockerfile +2 -1
- app.R +18 -45
- geo-llm-r.Rproj +1 -0
Dockerfile
CHANGED
|
@@ -8,9 +8,10 @@ RUN install2.r --error \
|
|
| 8 |
ggplot2 \
|
| 9 |
readr \
|
| 10 |
ggExtra \
|
| 11 |
-
mapgl \
|
| 12 |
duckdbfs
|
| 13 |
|
|
|
|
|
|
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
CMD ["R", "--quiet", "-e", "shiny::runApp(host='0.0.0.0', port=7860)"]
|
|
|
|
| 8 |
ggplot2 \
|
| 9 |
readr \
|
| 10 |
ggExtra \
|
|
|
|
| 11 |
duckdbfs
|
| 12 |
|
| 13 |
+
RUN installGithub.r cboettig/mapgl
|
| 14 |
+
|
| 15 |
COPY . .
|
| 16 |
|
| 17 |
CMD ["R", "--quiet", "-e", "shiny::runApp(host='0.0.0.0', port=7860)"]
|
app.R
CHANGED
|
@@ -1,58 +1,31 @@
|
|
| 1 |
library(shiny)
|
| 2 |
library(bslib)
|
| 3 |
-
library(
|
| 4 |
-
library(ggplot2)
|
| 5 |
-
|
| 6 |
-
df <- readr::read_csv("penguins.csv")
|
| 7 |
-
# Find subset of columns that are suitable for scatter plot
|
| 8 |
-
df_num <- df |> select(where(is.numeric), -Year)
|
| 9 |
|
|
|
|
| 10 |
ui <- page_sidebar(
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
choices = unique(df$Species), selected = unique(df$Species)
|
| 18 |
-
),
|
| 19 |
-
hr(), # Add a horizontal rule
|
| 20 |
-
checkboxInput("by_species", "Show species", TRUE),
|
| 21 |
-
checkboxInput("show_margins", "Show marginal plots", TRUE),
|
| 22 |
-
checkboxInput("smooth", "Add smoother"),
|
| 23 |
-
),
|
| 24 |
-
plotOutput("scatter")
|
| 25 |
)
|
| 26 |
|
| 27 |
server <- function(input, output, session) {
|
| 28 |
-
|
| 29 |
-
req(input$species)
|
| 30 |
-
df |> filter(Species %in% input$species)
|
| 31 |
-
})
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
)
|
| 43 |
|
| 44 |
-
if (input$show_margins) {
|
| 45 |
-
margin_type <- if (input$by_species) "density" else "histogram"
|
| 46 |
-
p <- p |> ggExtra::ggMarginal(
|
| 47 |
-
type = margin_type, margins = "both",
|
| 48 |
-
size = 8, groupColour = input$by_species, groupFill = input$by_species
|
| 49 |
-
)
|
| 50 |
-
}
|
| 51 |
|
| 52 |
-
p
|
| 53 |
-
},
|
| 54 |
-
res = 100
|
| 55 |
-
)
|
| 56 |
}
|
| 57 |
|
| 58 |
shinyApp(ui, server)
|
|
|
|
| 1 |
library(shiny)
|
| 2 |
library(bslib)
|
| 3 |
+
library(mapgl)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
pmtiles <- "https://data.source.coop/cboettig/us-boundaries/mappinginequality.pmtiles"
|
| 6 |
ui <- page_sidebar(
|
| 7 |
+
title = "mapgl with Shiny",
|
| 8 |
+
sidebar = sidebar(),
|
| 9 |
+
card(
|
| 10 |
+
full_screen = TRUE,
|
| 11 |
+
maplibreOutput("map")
|
| 12 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
server <- function(input, output, session) {
|
| 16 |
+
output$map <- renderMaplibre({
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
maplibre(center=c(-72.9, 41.3), zoom=10) |>
|
| 19 |
+
add_fill_layer(
|
| 20 |
+
id = "redlines",
|
| 21 |
+
source = list(type = "vector",
|
| 22 |
+
url = paste0("pmtiles://", pmtiles)),
|
| 23 |
+
source_layer = "mappinginequality",
|
| 24 |
+
fill_color = list("get", "fill")
|
| 25 |
+
)
|
| 26 |
+
})
|
|
|
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
|
| 31 |
shinyApp(ui, server)
|
geo-llm-r.Rproj
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
Version: 1.0
|
|
|
|
| 2 |
|
| 3 |
RestoreWorkspace: Default
|
| 4 |
SaveWorkspace: Default
|
|
|
|
| 1 |
Version: 1.0
|
| 2 |
+
ProjectId: 337131c5-7aa5-4963-bc4e-d8a156e206a0
|
| 3 |
|
| 4 |
RestoreWorkspace: Default
|
| 5 |
SaveWorkspace: Default
|