When I knit a document, sometimes it will hang on the third or fourth code chunk, continually spinning but never finishing. I can stop the rendering, but once that has happened rendering won't work anymore, even for other .Rmd files. I've tried restarting R and RStudio, clearing the Knitr cache, but nothing works except completely restarting my computer. Then I can reknit exactly the same file with no changes at all, and it works just fine... for a while... until suddenly it doesn't anymore. The problem does not always occur in the same document. I tried changing the preferences to use software rendering, but that didn't help either, even after restarting the computer and RStudio again.
I have a new 2021 MacBook Pro running Monterey 12.2.1. I tried updating R, Rstudio, and all the packages, so I'm running the latest version of everything. Nothing helped.