knitr: object cannot be found when converting markdown file into html

前端 未结 2 994
独厮守ぢ
独厮守ぢ 2020-12-17 05:18

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

相关标签:
2条回答
  • 2020-12-17 05:58

    Maybe I am missing something in your question, but if you create object 'cbt_2010' in your .Rmd file, knitr will have that object to work with.

    Stated differently, you can find it when you type object 'cbt_2010' at the console because you created that object and it is available to R. You need to do the same in the .Rmd file.

    0 讨论(0)
  • 2020-12-17 06:02

    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")
    
    0 讨论(0)
提交回复
热议问题