如何将内联代码添加到#|无花果帽:四分之一

发布于 2025-02-06 17:45:56 字数 1278 浏览 0 评论 0原文

更新:

@harre。我遇到了一个问题。

它可以与mtcars数据集完美。

但是,当我尝试使用已加载的数据框架时,它说:

Fehler in nrow(df_xxx) : Objekt 'df_xxx' nicht gefunden
Ruft auf: paste -> nrow
Fehler in yaml::yaml.load(meta, eval.expr = TRUE) : 
  Could not evaluate expression: paste(nrow(df_xxx), "blabla")
Ruft auf: .main ... FUN -> parse_block -> partition_chunk -> <Anonymous>
Ausf�hrung angehalten

在这种情况下,似乎是四分之一的外观#| ... df_xxx未生成。尽管它在环境中,我们无法访问它。 有什么想法吗?

原始问题: 这是一个工作的四重奏exmple:

---
title: "test"
format: revealjs
---

## Quarto example


```{r}
#| label: fig-plot_mtcars
#| fig-cap: nrow(mtcars).

plot(mtcars$mpg, mtcars$disp)
```

输出:

“在此处输入图像说明”

我如何将Inline代码添加到fig.cap:所需的输出:

我尝试了#|图帽:粘贴(“ bla”,nrow(mtcars))

Update:

@harre. I encountered an issue.

It works perfect with mtcars dataset.

But when I try to use a loaded dataframe it says:

Fehler in nrow(df_xxx) : Objekt 'df_xxx' nicht gefunden
Ruft auf: paste -> nrow
Fehler in yaml::yaml.load(meta, eval.expr = TRUE) : 
  Could not evaluate expression: paste(nrow(df_xxx), "blabla")
Ruft auf: .main ... FUN -> parse_block -> partition_chunk -> <Anonymous>
Ausf�hrung angehalten

It seems that quarto looks first #|... in this case df_xxx is not generated. Although it is in the environment we have no access to it.
Any idea?

Original question:
This is a working quarto exmple:

---
title: "test"
format: revealjs
---

## Quarto example


```{r}
#| label: fig-plot_mtcars
#| fig-cap: nrow(mtcars).

plot(mtcars$mpg, mtcars$disp)
```

output:

enter image description here

How can I add a inline code to fig.cap::
desired output:
enter image description here

I have tried with #| fig-cap: paste("bla", nrow(mtcars))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素食主义者 2025-02-13 17:45:56

您需要告诉四分之一的YAML您正在解析要评估的R表达式。 IE:

#| fig-cap: !expr nrow(mtcars)

有关参考,请参见:

https://quarto.org/computations/computations/ r.html#块

You'll need to tell the quarto YAML that you're parsing an R expression to be evaluated. I.e.:

#| fig-cap: !expr nrow(mtcars)

For reference, see:

https://quarto.org/docs/computations/r.html#chunk-options

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文