小编Phi*_*ip 的帖子

在 yml 文件中为四开指定参数

我正在 RStudio 中创建一个四开本书籍项目来渲染 html 文档。我需要在 yml 文件中指定一些参数,但 qmd 文件返回“未找到对象'params'”。使用 knitR。

我使用默认的 yml 文件,在 book 标签下添加了参数

project:
  type: book

book:
  title: "Params_TEst"
  author: "Jane Doe"
  date: "15/07/2022"
  params:
    pcn: 0.1
  chapters:
    - index.qmd
    - intro.qmd
    - summary.qmd
    - references.qmd

bibliography: references.bib

format:
  html:
    theme: cosmo
  pdf:
    documentclass: scrreprt

editor: visual
Run Code Online (Sandbox Code Playgroud)

qmd 文件看起来像这样

# Preface {.unnumbered}

This is a Quarto book.

To learn more about Quarto books visit <https://quarto.org/docs/books>.

```{r}
1 + 1
params$pcn
Run Code Online (Sandbox Code Playgroud)

当我渲染这本书或在 Rstudio 中预览这本书时,我收到的错误是:

从第 8-10 行退出 (index.qmd) eval(expr, …

rstudio knitr quarto

8
推荐指数
1
解决办法
4384
查看次数

在四开图书模板中将数据从一个 qmd 文件传递​​到另一个 qmd 文件?

我能否就在 RStudio 四开图书模板中将数据从一个四开文件传递到另一个四开文件的最佳实践寻求建议?

默认的书籍模板如下所示(_quarto.yml)

project:
  type: book

book:
  title: "TestTest"
  author: "Jane Doe"
  date: "08/06/2022"
  chapters:
    - index.qmd
    - intro.qmd
    - summary.qmd
    - references.qmd

bibliography: references.bib

format:
  html:
    theme: cosmo
  pdf:
    documentclass: scrreprt

editor: visual
Run Code Online (Sandbox Code Playgroud)

我将代码和文本放入文件中,例如index.qmd 和intro.qmd。我的问题是:这些文件似乎是相互独立的。如果我将数据从数据库读入index.qmd,那么intro.qmd 对此一无所知。那么如何最好地将数据从一个传递到另一个呢?我讨厌在数据库中查询每个 qmd 文件中的同一组数据。

任何帮助将非常感激。菲尔,

yaml r rstudio quarto

7
推荐指数
1
解决办法
1016
查看次数

如何在 geom_boxplot 上显示长标题?

我有一个很长的标题,我想将其包含在 ggplot 的底部geom_boxplot

目前,代码将一行写入标题,但缺少许多预期的标题。我如何将文字包裹在标题中?

我的代码是

p = ggplot(mpg, aes(class, hwy)) + geom_boxplot() +
  labs(title="An example title", caption = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in …
Run Code Online (Sandbox Code Playgroud)

markdown r caption ggplot2

1
推荐指数
1
解决办法
616
查看次数

标签 统计

quarto ×2

r ×2

rstudio ×2

caption ×1

ggplot2 ×1

knitr ×1

markdown ×1

yaml ×1