Jason
Jason

Reputation: 71

Can't knit an RStudio into an HTML document

I have an RStudio session open and need to knit it into an HTML document. I'm trying to do it through the knit button but I'm getting a popup that says this:

Loading required package: knitr Warning message: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘knitr’ Error in knit("jorge_perez_ruano_uber_final.Rhtml", encoding = "UTF-8") : could not find function "knit" Execution halted

knitr terminated with status 1

I have installed the markdown package and also tried to run the render function but it's giving me another error:

Error in render("path/to/file.Rmd") : could not find function "render"

Anyone knows how to help?

Upvotes: 0

Views: 2063

Answers (1)

mhovd
mhovd

Reputation: 4087

The error is in the error - you did not have knitr installed.

Install the package with install.packages("knitr"), and you should be ready to go. Remember that the markdown environment should be considered separate from the global environment, and as such you need to load relevant libraries and code in a code chunk before it is accessible. Here is a good introduction to the topic.

Upvotes: 1

Related Questions