在RStudio预览版中编织Html的问题

在RStudio预览版中编织Html的问题,第1张

概述我已经问过相关问题 here, here和 here. 目标 我有一个很长的Rmd文件(保存在R项目中),我想用目录编织成Html和PDF. 问题背景 我之前使用的是RStudio 0.98.501.设置是: >文档顶部没有目录(TOC)命令 >外部图像的绝对路径 >全局块选项中的cache = TRUE 当我第一次点击knitHtml按钮创建新文件夹时:数字,缓存,knitHTML等等.没有问题 我已经问过相关问题 here,here和 here.

目标

我有一个很长的Rmd文件(保存在R项目中),我想用目录编织成HTML和pdf.

问题背景

我之前使用的是RStudio 0.98.501.设置是:

>文档顶部没有目录(TOC)命令
>外部图像的绝对路径
>全局块选项中的cache = TRUE

当我第一次点击knitHTML按钮创建新文件夹时:数字,缓存,knitHTML等等.没有问题,一切正常.但后来我决定添加TOC.使用Rmarkdown Version 2 page的“输出选项”部分,我在顶部添加了toc命令,单击了knitHTML按钮,但获得了与之前完全相同的输出,没有任何TOC.所以,我决定升级到RStudio PrevIEw版本.

当前的问题状态

更新到预览版后,我打开了项目并单击了knitHTML按钮.它给出了一个错误,即找不到其中一个外部图像.因此,在谢毅辉的建议下,我做了以下事情:

>复制前一个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.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.0\rmarkdown\rmd\h\highlight pandoc.exe: Could not find data file ./Trajectory1-new_files/figure-HTML/pdf_veLocity.pngError: pandoc document conversion Failed with error 97In 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 used2: 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.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.0\rmarkdown\rmd\h\highlight' had status 97 Execution halted

所以,我尝试编织pdf并且它有效.输出与预期一致.然后我在全局块选项中更改为cache = FALSE并单击编织HTML.花了很长时间(我的文件有很多分析)并给出了带有TOC的HTML文件作为输出,我需要的.

我的问题是,为什么我必须将cache = FALSE用于创建HTML,当缓存= TRUE适用于RStudio预览版中的pdf时?我只能在添加一个部分后每次等待15-20分钟才能看到输出.我该如何解决这个问题?

编辑

以下是前面的事情:

---Title: "Sample document"output:  HTML_document:    theme: united    toc: yes---Trajectory: 7:50 am - 8:05 am (t1)========================================================```{r setup}# set global chunk options: library(knitr)opts_chunk$set(cache=TRUE,fig.align='center')``````{r alllibrarIEs,echo=FALSE}library(ggplot2)library(plyr)library(data.table)library(parallel)library(xtable)library(ggthemes)suppresspackageStartupMessages(library(GoogleVis))my.theme<-function(base_size = 12,base_family = "Trebuchet MS"){theme(plot.Title = element_text(size = rel(2)),panel.grID.major=element_line(color='grey'),panel.grID.minor=element_line(color='grey',linetype='dashed'),legend.position='bottom',legend.background = element_rect(colour = "black"),strip.text = element_text(size=13,lineheight=2))}```
解决方法 这可能仅作为评论,但它对我有用.

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

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

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

总结

以上是内存溢出为你收集整理的在RStudio预览版中编织Html的问题全部内容,希望文章能够帮你解决在RStudio预览版中编织Html的问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1080345.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存