Thanks, Kevin. It seems opts$external.packages can solve this
particular problem, but it may violate principles of reproducibility,
since there is no guarantee the versions of external packages are what
was specified in the packrat.lock file (or there is?). At the moment,
I don't mind reinstalling a package if the project author requires a
different version in the lock file. It is just that I don't want to
reinstall the same version. I guess there is a lot of redundancy by
reinstalling everything, and we don't necessarily lose reproducibility
by using some packages from the system's global R package libraries as
long as the version requirement is satisfied.
Regards,
Yihui