Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
RStudio预览版中编织Html的问题_R_Knitr_Rstudio - Fatal编程技术网

RStudio预览版中编织Html的问题

RStudio预览版中编织Html的问题,r,knitr,rstudio,R,Knitr,Rstudio,我已经问了相关的问题,还有 目标 我有一个很长的Rmd文件(保存在一个R项目中),我想用目录将它编织成Html和PDF 问题背景 我以前使用的是RStudio 0.98.501。设置为: 文档顶部没有目录(TOCs)命令 外部图像的绝对路径 cache=TRUE在全局块选项中 当我第一次单击knitHtml按钮时,它创建了新文件夹:figures,cache,knitHtml,等等。没有问题,一切正常。但后来我决定加入TOC。使用的Output Options部分,我在顶部添加了toc命令,单击

我已经问了相关的问题,还有

目标 我有一个很长的Rmd文件(保存在一个R项目中),我想用目录将它编织成Html和PDF

问题背景 我以前使用的是RStudio 0.98.501。设置为:

  • 文档顶部没有目录(TOCs)命令
  • 外部图像的绝对路径
  • cache=TRUE
    在全局块选项中
  • 当我第一次单击
    knitHtml
    按钮时,它创建了新文件夹:
    figures
    cache
    knitHtml
    ,等等。没有问题,一切正常。但后来我决定加入TOC。使用的
    Output Options
    部分,我在顶部添加了toc命令,单击了
    knitHtml
    按钮,但得到了与之前相同的输出,没有任何toc。所以,我决定升级到RStudio预览版

    问题的现状 更新到预览版本后,我打开了项目并单击了
    knitHtml
    按钮。它给出的错误是找不到一个外部图像。因此,在谢一辉的建议下,我做了以下几点:

    opts_chunk$set(cache=TRUE, cache.path = 'DocumentName_cache/', fig.path='figure/')
    
    • 复制了R在上一阶段创建的所有外部图像和绘图 编织到Rmd文件所在的文件夹。这是项目目录中的
      knitHtml
      文件夹
    • 所有外部图像的相对路径
    • cache=TRUE
      在全局块选项中
    然后我单击了
    knitHTML
    按钮,得到了以下错误:

    output file: Trajectory1-new.knit.md
    "C:/Program Files/RStudio/bin/pandoc/pandoc" Trajectory1-new.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Trajectory1-new.html --smart --email-obfuscation none --self-contained --standalone --section-divs --table-of-contents --toc-depth 3 --template C:\Users\durraniu\Documents\R\win-library\3.0\rmarkdown\rmd\h\default.html --variable theme:united --include-in-header C:\Users\durraniu\AppData\Local\Temp\Rtmp0OFfmZ\rmarkdown-str10186bd23276.html --mathjax --variable mathjax-url:https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML --no-highlight --variable highlightjs=C:\Users\durraniu\Documents\R\win-library\3.0\rmarkdown\rmd\h\highlight 
    pandoc.exe: Could not find data file ./Trajectory1-new_files/figure-html/pdf_velocity.png
    Error: pandoc document conversion failed with error 97
    In addition: Warning messages:
    1: In if (grepl(" ", path, fixed = TRUE)) path <- utils::shortPathName(path) :
      the condition has length > 1 and only the first element will be used
    2: running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" Trajectory1-new.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output Trajectory1-new.html --smart --email-obfuscation none --self-contained --standalone --section-divs --table-of-contents --toc-depth 3 --template C:\Users\durraniu\Documents\R\win-library\3.0\rmarkdown\rmd\h\default.html --variable theme:united --include-in-header C:\Users\durraniu\AppData\Local\Temp\Rtmp0OFfmZ\rmarkdown-str10186bd23276.html --mathjax --variable mathjax-url:https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML --no-highlight --variable highlightjs=C:\Users\durraniu\Documents\R\win-library\3.0\rmarkdown\rmd\h\highlight' had status 97 
    Execution halted
    

    这可能只是一个评论,但对我来说很有效

    因为我最初在旧版本的RStudio(0.98.501)中创建了项目和标记文档,然后切换到预览版本,所以我认为有必要在块选项中指定图形和缓存路径。因此,我做了以下工作:

    opts_chunk$set(cache=TRUE, cache.path = 'DocumentName_cache/', fig.path='figure/')
    

    现在,我不必保持
    cache=FALSE
    来连接HTML。在预览版中,我现在可以轻松创建目录并更改主题。

    请始终在帖子中包含软件版本,如果有新版本,请更新软件包。此外,如果没有一个最小的可复制的例子,很难回答一个问题。我使用的RStudio的预览版本是0.98.894。我已经更新了所有的软件包。另外,创建一个最小的可复制示例就是尝试用一个较小的文档创建相同的问题。我试过了,但在较小的文档中并没有问题(无论是否使用
    cache=TRUE
    ,文件都很容易编写)。我不知道到底是什么阻止了pandoc将md文件转换成html。误差为97。我在谷歌上搜索了一下,但找不到任何信息。请引导。我再次更新了包,现在R找不到任何包!我正在恢复到旧版本。这似乎是目前唯一的解决方案。你能至少发布你的Rmd文件的YAML frontmatter吗?我已经发布了frontmatter