When collaborating on Rmds and their knit outputs, what's everyone's best practice for including/not including install.packages() in the R markdown file?
In the past, when I was leading a team, my practice was just to use the library() call in Rmarkdown and let the errors inform the user on what packages they need to install if they need to re-knit the output.
I just joined a new team where the person I'm backfilling always used a call to install.packages() for every package in his Rmd's first chunk, with the second chunk including all the library() calls.
I don't know if there's any agreement on best practice(s) in the community regarding installing or not installing packages directly from the Rmd file...
I would say: don't ever put install.packages() in to an Rmd (or an R script for that matter).
Attach pacakges with library(), and let the user discover that they don't have a package installed that way. (And RStudio will also alert you if you are missing a required package).
That way, errors/problems during package installation are easier to see/not tangled up with running the Rmd/R script.