-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e9df4a
commit ab48f99
Showing
6 changed files
with
355 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
4-parameters-interactivity-deployment/_parameters-class-compact-r.qmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
title: "Parameters" | ||
format: | ||
dashboard: | ||
logo: images/beetle.png | ||
params: | ||
class: "compact" | ||
--- | ||
|
||
```{{r}} | ||
library(ggplot2) | ||
library(dplyr) | ||
mpg <- mpg |> | ||
filter(class == params$class) | ||
``` | ||
|
||
## Value boxes {height="25%"} | ||
|
||
::: {.valuebox icon="car-front-fill" color="info"} | ||
Class | ||
|
||
`{r} params$class` | ||
::: | ||
|
||
```{{r}} | ||
#| label: calculate-values | ||
lowest_mileage_cty <- mpg |> | ||
filter(cty == min(cty)) |> | ||
distinct(cty) |> | ||
pull(cty) | ||
highest_mileage_cty <- mpg |> | ||
filter(cty == max(cty)) |> | ||
distinct(cty) |> | ||
pull(cty) | ||
rounded_mean_city_mileage <- mpg |> | ||
summarize(round(mean(cty), 2)) |> | ||
pull() | ||
``` | ||
|
||
```{{r}} | ||
#| content: valuebox | ||
#| title: "Least efficient" | ||
#| icon: fuel-pump-fill | ||
#| color: danger | ||
list( | ||
value = paste(lowest_mileage_cty, "mpg") | ||
) | ||
``` | ||
|
||
```{{r}} | ||
#| content: valuebox | ||
#| title: "Most efficient" | ||
list( | ||
icon = "fuel-pump", | ||
color = "success", | ||
value = paste(highest_mileage_cty, "mpg") | ||
) | ||
``` | ||
|
||
::: {.valuebox icon="fuel-pump" color="secondary"} | ||
Average city mileage | ||
|
||
`{r} rounded_mean_city_mileage` mpg | ||
::: | ||
|
||
## Plots {height="75%"} | ||
|
||
```{{r}} | ||
#| title: Highway vs. city mileage | ||
ggplot(mpg, aes(x = cty, y = hwy)) + | ||
geom_point() | ||
``` | ||
|
||
```{{r}} | ||
#| title: Drive types | ||
ggplot(mpg, aes(x = drv)) + | ||
geom_bar() | ||
``` |
80 changes: 80 additions & 0 deletions
80
4-parameters-interactivity-deployment/_parameters-class-midsize-r.qmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
title: "Parameters" | ||
format: | ||
dashboard: | ||
logo: images/beetle.png | ||
params: | ||
class: "midsize" | ||
--- | ||
|
||
```{{r}} | ||
library(ggplot2) | ||
library(dplyr) | ||
mpg <- mpg |> | ||
filter(class == params$class) | ||
``` | ||
|
||
## Value boxes {height="25%"} | ||
|
||
::: {.valuebox icon="car-front-fill" color="info"} | ||
Class | ||
|
||
`{r} params$class` | ||
::: | ||
|
||
```{{r}} | ||
#| label: calculate-values | ||
lowest_mileage_cty <- mpg |> | ||
filter(cty == min(cty)) |> | ||
distinct(cty) |> | ||
pull(cty) | ||
highest_mileage_cty <- mpg |> | ||
filter(cty == max(cty)) |> | ||
distinct(cty) |> | ||
pull(cty) | ||
rounded_mean_city_mileage <- mpg |> | ||
summarize(round(mean(cty), 2)) |> | ||
pull() | ||
``` | ||
|
||
```{{r}} | ||
#| content: valuebox | ||
#| title: "Least efficient" | ||
#| icon: fuel-pump-fill | ||
#| color: danger | ||
list( | ||
value = paste(lowest_mileage_cty, "mpg") | ||
) | ||
``` | ||
|
||
```{{r}} | ||
#| content: valuebox | ||
#| title: "Most efficient" | ||
list( | ||
icon = "fuel-pump", | ||
color = "success", | ||
value = paste(highest_mileage_cty, "mpg") | ||
) | ||
``` | ||
|
||
::: {.valuebox icon="fuel-pump" color="secondary"} | ||
Average city mileage | ||
|
||
`{r} rounded_mean_city_mileage` mpg | ||
::: | ||
|
||
## Plots {height="75%"} | ||
|
||
```{{r}} | ||
#| title: Highway vs. city mileage | ||
ggplot(mpg, aes(x = cty, y = hwy)) + | ||
geom_point() | ||
``` | ||
|
||
```{{r}} | ||
#| title: Drive types | ||
ggplot(mpg, aes(x = drv)) + | ||
geom_bar() | ||
``` |
Oops, something went wrong.