Is there any way to add packages that knitr doesn't know? I use knitr in Overleaf, and I need to use packages "pacma", "nonlinearTseries" and "RHRV". But when I tried to install them it didn't work. I tried do add them with library function but it get me an error massage.
library("RHRV")
Error in library("RHRV"): there is no package called ’RHRV’
Unfortunately, installing a package on Overleaf is not possible, see e.g. https://tex.stackexchange.com/questions/566054/cannot-install-r-packages-in-the-knitr-environment-overleaf
You could try to contact the team behind Overleaf and ask them politely, but they can have reasons why they cannot help you.
As Overleaf is simply a TeX distribution and compiliation, with some R thrown into it, you you could consider installing R locally. Installing a TeX distribution can be more overwhelming than installing a operating system. Luckily, for knitr
, the author behind made an R-package, tinytex
(https://yihui.org/tinytex/) - which does almost everything for you.