gpt4 book ai didi

r - 使用 `devtools::build_vignette` 编译小插图,以便 .md 保存在小插图目录中

转载 作者:行者123 更新时间:2023-12-04 23:14:47 24 4
gpt4 key购买 nike

我正在尝试编译一个包小插图,以便 .md 文件保留在小插图文件夹中,以便它在 github 上仍然可见。我正在使用 devtools对于这一切。我看过这个 approach并将在下面概述:

我已经自动生成了一个小插图模板使用 devtools::use_vignette() .然后我修改了.Rmd文件看起来像这样(截断的模板版本):

---
title: "package"
author: "author"
date: "`r Sys.Date()`"
output:
rmarkdown::html_vignette:
toc: true
keep_md: true
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The `html_vignette` output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The `html_vignette` format:

- Never uses retina figures
- Has a smaller default figure size
- Uses a custom CSS stylesheet instead of the default Twitter Bootstrap style

## Vignette Info

Note the various macros within the `vignette` section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the `title` field and the `\VignetteIndexEntry` to match the title of your vignette.

所以 .yaml被修改但是当我使用 devtools::build_vignettes() 编译时它似乎没有留下 .md小插图目录中的文件。没有错误消息,小插图构建良好,所以这有点令人困惑。

所以总结一下这个问题,有没有人知道如何使用 devtools::build_vignette 编译一个小插图?这样基本的 Markdown 文件保存在小插图目录中?

最佳答案

如果您对 build_vignette() 以外的功能持开放态度,那么这很容易,因为归根结底,一切都只是外部 pandoc 的包装器。二进制。

/tmp/vig> ls -l     ## start with nothing but Rmd
total 4
-rw-r--r-- 1 user grp 1015 Aug 10 14:21 soVig.Rmd
/tmp/vig>
/tmp/vig> Rscript -e 'rmarkdown::render("soVig.Rmd", clean=FALSE)'


processing file: soVig.Rmd
|.................................................................| 100%
inline R code fragments


output file: soVig.knit.md

/usr/bin/pandoc +RTS -K512m -RTS soVig.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output soVig.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /usr/local/lib/R/site-library/rmarkdown/rmd/h/default.html --highlight-style pygments --css /usr/local/lib/R/site-library/rmarkdown/rmarkdown/templates/html_vignette/resources/vignette.css --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'

Output created: soVig.html
/tmp/vig> ls -l soVig.*
-rw-r--r-- 1 user grp 7066 Aug 10 14:24 soVig.html
-rw-r--r-- 1 user grp 1011 Aug 10 14:24 soVig.knit.md
-rw-r--r-- 1 user grp 1015 Aug 10 14:21 soVig.Rmd
-rw-r--r-- 1 user grp 1011 Aug 10 14:24 soVig.utf8.md
/tmp/vig>

所以只需告诉 render()为了不清理,我们可以保留 Markdown 源。

关于r - 使用 `devtools::build_vignette` 编译小插图,以便 .md 保存在小插图目录中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45575971/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com