Picture by Tonik

A very short primer on updating R to 4.0.0 and re-installing all packages


My experience with updating to 4.0.0 was quite unspectacular. Below I describe how the update went and how to reinstall all packages—which worked without problems so far.


Installation process for macOS Catalina

For the update to work I had to install the following programs:


My packages

I re-installed all packages I routinely use or like to play with. To do so, I looked at my most recent analyses and extracted all relevant packages. In my particular case, these are mostly relevant for:

  1. research synthesis
  2. data cleaning
  3. data visualization
  4. psychometrics
  5. statistical modeling
  6. blogging with Hugo

Most of these packages are listed on CRAN, and are easy to install via install.packages():

# data wrangling and set up
install.packages(c("tidyverse",   # data wrangling and visualization
                   "janitor",     # cleaning dirty data fast
                   "pacman"))     # loading multiple packages at once

# tables and descriptive stats
install.packages(c("officer",     # exporting word files
                   "qwraps2",     # wrapper function for descriptive tables
                   "flextable",   # easily create tables
                   "broom",       # tidy outputs
                   "summarytools",# fast descriptive statistics
                   "kableExtra")) # for tables       

# data visualization
install.packages(c("plotly",      # interactive, publication-quality graphs
                   "gridExtra",   # easily combine mulitple plots
                   "grid",        # easily combine mulitple plots
                   "viridis",     # color palette for colorblindness
                   "wesanderson", # favorite yet impractical color palette
                   "nord",        # beautiful color palette
                   "hrbrthemes",  # reasonable color palette
                   "corrplot",    # correlogram
                   "PerformanceAnalytics")) # correlation matrix

# modeling
install.packages(c("lme4",         # linear mixed-effects models
                   "lmerTest",     # tests in linear mixed effects models
                   "broom.mixed")) # tidying methods for mixed models
                 
# psychometrics
install.packages(c("psychonetrics", # network psychometrics
                   "psych"))        # general purpose toolbox

# research synthesis
install.packages(c("metafor",     # 2- and 3-level meta-analysis
                   "metaviz",     # advanced data visualization
                   "psychmeta",   # psychometric meta-analysis
                   "metaSEM",     # meta-analyses in SEM framework
                   "metaforest")) # random forest meta-analyses

# p-curve & p-uniform
install.packages("puniform")   # p-uniform analyis

I then looked at the warnings and remembered: Some packages are not available on CRAN, for example dmetar:

install.packages("dmetar")

So you need to first install devtools:

install.packages("devtools")

And install those packages via github

devtools::install_github("MathiasHarrer/dmetar")

You should be able to install most packages that give you a warning by looking at the documentation/vignette!

If you encounter any additional problems, this post on stackoverflow should cover most of them!


Blogging with Hugo/Academics

This is how I re-installed blogdown and Hugo, and as you can see by reading my blog, this worked well:

install.packages('blogdown') 
                 
library(blogdown)

blogdown::install_hugo(force = TRUE)


Loading the favorite packages

I know this is might not be considered best practice, but from now on out I will probably load my favorite R packages all at once, so I have everything I need for most of the challenges/analyses I encounter.

Generally, I like pacman´s p_load() function for loading and installing packages. If you don´t have a package, it installs and loads it for you, if you have it installed, it only loads it.

# data wrangling
pacman::p_load(tidyverse, # data wrangling and visualization
               janitor)   # cleaning dirty data fast 
 
# tables and descriptive stats
pacman::p_load("officer",     # exporting word files
               "qwraps2",     # wrapper function for descriptive tables
               "flextable",   # easily create tables
               "broom",       # tidy outputs
               "summarytools",# fast descriptive statistics
               "kableExtra")  # for tables       

# data visualization
pacman::p_load("plotly",      # interactive, publication-quality graphs
               "gridExtra",   # easily combine mulitple plots
               "grid",        # easily combine mulitple plots
               "viridis",     # color palette for colorblindness
               "wesanderson", # favorite yet impractical color palette
               "nord",        # beautiful color palette
               "hrbrthemes",  # reasonable color palette
               "corrplot",    # correlogram
               "PerformanceAnalytics") # nice correlation matrix

# modeling
pacman::p_load("lme4",         # linear mixed-effects models
               "lmerTest",     # tests in linear mixed effects models
               "broom.mixed")  # tidying methods for mixed models

# psychometrics
pacman::p_load("psychonetrics", # network psychometrics
               "psych")         # general purpose toolbox

# research synthesis
pacman::p_load("metafor",     # 2- and 3-level meta-analysis
               "metaviz",     # advanced data visualization
               "psychmeta",   # psychometric meta-analysis
               "metaSEM",     # meta-analyses in SEM framework
               "metaforest")  # random forest meta-analyses

# p-curve & p-uniform
pacman::p_load("dmetar",      # p-curve and additional analyses
               "puniform")   # p-uniform analyis

Conclusion

Overall I quite enjoyed this process of having a blank slate and thinking about which packages to re-install but this is easy to say as I did not encounter any problems :)

Good luck!