Code is running but Knit to HTML does not work


Some things to check when knitting fails, but the code runs manually:

  • Are all package libraries specified in the markdown code (sometimes you activated them before, outside the code but during knitr it needs to reload them)
  • Are there any variables in the current environment that are not created in the code (same issue as with libraries as markdown cannot access environment variables outside the code). Clear the environment in R-Studio (removing all variables) and see if you can still run code manually.
  • Are you loading any external data? Check if the paths are correct, as knitr does not use the working directory but the root of the project (or R)

If non help, please create a minimal reproducible example

Hope this helps,