在Quarto的YAML中使用路径

问题描述 投票:0回答:1

我正在一个文件夹中创建多个仪表板。假设我们有一个包含这些仪表板徽标的子文件夹。我想在每个文档的 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)
```

输出:

enter image description here

如您所见,徽标未显示在左上角。所以我想知道是否有人知道如何在

Quarto
的yaml中使用相对路径?

r yaml dashboard quarto
1个回答
0
投票

也许您已经找到了解决方案,如果没有: 诀窍是在名为“www”的文件夹中找到徽标文件 你的 YAML 应该是这样的

---
title: "Palmer Penguins"
author: "Quinten"
format:
  dashboard:
    embed-resources: true
logo: www/penguins.png
theme:
  - zephyr
---

然后您将获得带有徽标的四开仪表板:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.