Hello!
I have a working R Markdown script but when I try to knit it, R Markdown gives the following error:
Error in loadNamespace(name) : there is no package called 'rmarkdown'
Calls: :: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
The package is installed, I tried removing and reinstalling it but got the same error.
The package is listed in installed.packages().
I should maybe add that I edited my Rprofile because I wasn't happy with the default location for packages (inspired by this post):
myPaths <- .libPaths()
myPaths <- myPaths[2]
.libPaths(myPaths)
Is R Markdown maybe looking for the package in the old directory?
Also, I'm using the most recent versions of R (3.6.0) and RStudio (1.2.1335).
The RStudio Knit button should also work though. Where is your .Rprofile saved? The line below checks if it is saved in your user directory (if you're on Windows it will be in Documents).
file.exists("~/.Rprofile")
Also, have you tried setting the environment variable R_LIBS_USER to your preferred library location? I think that may be a more robust solution to your problem (and easier to read). For example, if you create the file ~/.Renviron and add the line R_LIBS_USER="/path/to/my/preferred/location", the first path in .libPaths() will be that preferred path.