我正在一个文件夹中创建多个仪表板。假设我们有一个包含这些仪表板徽标的子文件夹。我想在每个文档的 YAML 标头中使用相对路径提及这些徽标。它不起作用,所以我尝试了这个,如何使用here()作为css、before_body和after_body的路径?。不幸的是这不起作用。在这里我创建了一些可重现的代码:
---
title: "Palmer Penguins"
author: "Quinten"
format:
dashboard:
embed-resources: true
logo: !expr here::here("logos/penguins.png")
theme:
- zephyr
---
```{r}
# import packages
library(tidyverse)
library(crosstalk)
library(DT)
library(plotly)
library(gt)
library(palmerpenguins)
# import data
penguins <- palmerpenguins::penguins
# Crosstalk dataset
shared_penguins <- SharedData$new(penguins)
# Set theme
theme_set(theme_minimal())
```
# {.sidebar}
This is a simple static dashboard to show what is possible with the newest version of [Quarto v1.4](https://quarto.org/docs/blog/posts/2024-01-24-1.4-release/). To make it a bit interactive we use the [crosstalk](https://github.com/rstudio/crosstalk) package and [plotly](https://plotly.com/r/).
***
In this dashboard we visualize the [palmerpenguins](https://allisonhorst.github.io/palmerpenguins/) dataset. In the table below is some basic information about the data:
| Specie | Count |
|--------------|---------------------|
| **Adelie** | `{r} nrow(subset(penguins, species == "Adelie"))` |
| **Gentoo** | `{r} nrow(subset(penguins, species == "Gentoo"))` |
| **Chinstrap** | `{r} nrow(subset(penguins, species == "Chinstrap"))` |
```{r}
filter_checkbox("sex", "Sex", shared_penguins, ~sex)
```
***
# Analysis
## Row {height=40%}
### Column {width=80%}
```{r}
#| title: "Slider options"
slider_width = 800
htmltools::div(
id = "sliderdiv",
filter_slider("bill_length_mm", "bill length", shared_penguins, ~bill_length_mm, width = slider_width),
filter_slider("bill_depth_mm", "bill depth", shared_penguins, ~bill_depth_mm, width = slider_width),
filter_slider("flipper_length_mm", "flipper length", shared_penguins, ~flipper_length_mm, width = slider_width),
filter_slider("body_mass_g", "body mass", shared_penguins, ~body_mass_g, width = slider_width)
)
```
### Column {width=20%}
```{r}
#| content: valuebox
#| title: "Number of penguins"
list(
icon = "tencent-qq",
color = "primary",
value = nrow(penguins)
)
```
## Row {height=60%}
```{r}
#| title: "Flipper length vs body mass"
p <- ggplot(shared_penguins, aes(x = flipper_length_mm, y = body_mass_g, color = species, shape = species)) +
geom_point() +
scale_color_manual(values = c("darkorange","darkorchid","cyan4"))
ggplotly(p)
```
```{r}
#| title: "bill length by species"
p <- ggplot(data = penguins, aes(x = species, y = bill_length_mm)) +
geom_boxplot(alpha = 0.2) +
geom_jitter(aes(color = species),
width = 0.1,
alpha = 0.7,
show.legend = FALSE) +
scale_color_manual(values = c("darkorange","darkorchid","cyan4"))
ggplotly(p)
```
输出:
如您所见,徽标未显示在左上角。所以我想知道是否有人知道如何在
Quarto
的yaml中使用相对路径?