Why do I have to install RMarkdown to knit?

Please ask your questions about R Markdown here.I have the RMarkdown package installed, even though I read that RStudio (4.0.2) installs it and loads it anyway.

I run my chunks and everything works fine, but when I come to knit, R opens the RMarkdown console, with this error, even though I can see it's installed.

I have found similar questions about this error with other packages, but RMarkdown is critical to the knit process so I don't get why Knit throws this error

Error in loadNamespace(name) : there is no package called 'rmarkdown'
Calls: :: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted

Where do I need to install the rmarkdown package to?

There's a marked solution for this issue here:

Try running

library(rmarkdown)
render("path/to/file.Rmd")

For the source of the issue with the knit button, this is a little confusing to me. The only difference between rmarkdown::render() in your console and clicking the knit button is that the button runs render in a new session.

Yihui has some discussion of what's going on with here

2 Likes

It should definitly work with the knit button. rmarkdown :package: must be installed in your user library so that it is found by Rstudio to render.

I let you try @EconomiCurtis advice before investigating further to see if at least it works from your R console.

Thanks, that was very helpful.

I found out the render command worked correctly from the console, but the knit button did not even if they should do the same thing. So the problem was not rmarkdown, it was knitr calling rmarkdown.

So I deleted and reinstalled knitr and everything works well.

1 Like

Glad it works!

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.