Packages that you install in R are tied to a particular version of R, so after installing a new version none of your previously
installed pacakges will remain. I tend to think of this as a feature (time for a spring clean...), and then just reinstall
pacakges that I know I need (e.g. install.packages(c("tidyverse", "usethis", "devtools"))) and continue to install pacakges as
I realise that I need them.
However, if you really want to reinstall the previous set of packages, the steps below will help. First, we collect a list of packages that were installed from CRAN and a list of packages that were installed from GitHub repositories. Once we have those lists, after intalling the new version of R we can load the list of those packages and reinstall them.