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
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.
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")