Dashboard code
Exercise 11 — PMAP 8551/4551, Fall 2025
Here’s the code for creating the dashboard:
dashboard.qmd
---
title: Dashboard
format: dashboard
---
```{r}
#| warning: false
#| message: false
library(tidyverse)
library(plotly)
library(leaflet)
# Technically this isn't necessary; you can run `penguins` and start using it
# right away since it's a core dataset. This code just puts the dataset in the
# environment panel so it's easier to see what's in there.
penguins <- datasets::penguins
# 11 rows are missing data on penguin sex, so we drop them
penguins <- penguins |>
drop_na(sex)
```
## Row
```{r}
#| title: "Palmer Station, Antarctica"
palmer_coords <- list(lng = -64.053, lat = -64.774)
leaflet() |>
addTiles() |>
setView(
lng = palmer_coords$lng,
lat = palmer_coords$lat,
zoom = 16
) |>
addMarkers(
lng = palmer_coords$lng,
lat = palmer_coords$lat,
popup = "Home of the famous penguins"
)
```
## Row
### Column
```{r}
#| content: valuebox
#| title: "Number of islands"
list(
icon = "globe-americas",
color = "#d1f0ff",
value = length(unique(penguins$species))
)
```
```{r}
#| content: valuebox
#| title: "Favorite food"
list(
icon = "fork-knife",
color = "#ffe5db",
value = "Fish"
)
```
### Column
```{r}
#| title: "Bill length and bill depth"
p <- ggplot(penguins, aes(x = bill_dep, y = bill_len, color = species)) +
geom_point() +
scale_color_manual(values = c("darkorange", "purple", "cyan4")) +
theme_light()
ggplotly(p)
```