代码之家  ›  专栏  ›  技术社区  ›  user1981275

使用R CMD build在vignette中未应用R标记主题

  •  3
  • user1981275  · 技术社区  · 6 年前

    我正在尝试用一个特定的主题制作一个html包vignette,示例如下 hpstr 主题来自 prettydoc公司 (` https://github.com/yixuan/prettydoc/blob/master/vignettes/hpstr.Rmd ).

    如果我手动构建渐晕图:

    rmarkdown::render('vignettes/hpstr.Rmd', output_format='prettydoc::html_pretty')

    主题应用正确。但是,当我使用标准构建过程时,例如:

    git clone https://github.com/yixuan/prettydoc.git
    cd prettydoc
    R CMD build .
    R CMD INSTALL prettydoc_0.2.1.tar.gz
    

    然后,在R中:

    > library('prettydoc')
    > vignette('hpstr')
    

    主题根本没有渲染,它看起来像一个常规的 html_output .

    渐晕图顶部的yml如下所示:

    ---
    title: "Creating Pretty Documents from R Markdown"
    subtitle: "The HPSTR Theme"
    author: "Yixuan Qiu"
    date: "`r Sys.Date()`"
    output:
      prettydoc::html_pretty:
        theme: hpstr
        highlight: github
    vignette: >
      %\VignetteIndexEntry{Creating Pretty Documents from R Markdown - The HPSTR Theme}
      %\VignetteEngine{knitr::rmarkdown}
      %\VignetteEncoding{UTF-8}
    ---
    

    而在 DESCRIPTION 文件指定了渐晕图生成器:

    VignetteBuilder: knitr, rmarkdown
    

    所以,这个小插曲的构建者似乎不是 rmarkdown::render .

    如何使用自动应用主题 R CMD build ?

    1 回复  |  直到 6 年前
        1
  •  2
  •   Ralf Stubner    6 年前

    如果pandoc未在系统级安装或安装到旧版本,而RStudio附带自己的pandoc版本,则可能会发生这种情况。因此,在RStudio中渲染成功,而在 R CMD build .可能的解决办法:

    • 在系统级别安装或更新pandoc
    • 使随RStudio提供的pandoc在系统级可用
    • 在RStudio中构建包(由@YihuiXie建议)