knitr:将markdown文件转换为html时找不到对象 [英] knitr: object cannot be found when converting markdown file into html

查看:1394
本文介绍了knitr:将markdown文件转换为html时找不到对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R studio和"knitHTML"按钮将我的Rmd文件转换为html文件.但是,即使认为代码运行正常,使用knitHTML时也找不到我以前创建的任何对象:

Hi I am using R studio and the "knitHTML" button to convert my Rmd file into a html file. However, even thought the code runs fine, when using knitHTML it cannot find any of my objects previously created:

## Error: object 'cbt_2010' not found

但是,如果我在终端上键入cbt_2010-在那里.基本而言,编织找不到工作空间中的任何对象.

however if I type cbt_2010 at the terminal - it is there. Bascially knit cannot find any of the objects in the workspace.

我在做什么错?似乎使用编织时每个块中产生的任何数据都会丢失在内存中!

what am I doing wrong? it just seems any data produced in each chunk is lost in memory when using knit!

推荐答案

如@BenBolker所述,您可以使用knit2html(请注意,它与Rstudio按钮不同,Rstudio使用其自身的功能来处理文档)来自knitr:

As already mentioned by @BenBolker , you can use knit2html( Note that it is different from the Rstudio button, Rstudio use its own function to process document) from knitr:

 x <- 10
 writeLines(c("# hello markdown",
          "```{r hello-random, echo=TRUE}", 
               "rnorm(x)", "```"), ## note the use of x
 "test.Rmd")
 library(knitr)
 knit2html("test.Rmd")

这篇关于knitr:将markdown文件转换为html时找不到对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆