Chapter 12 Packages

  • Many objects (functions, data sets etc) are stored in packages (see here)
  • Packages are written by various authors and can be loaded for an R session to use their content
  • e.g. Yves Rosseel works on the package Lavaan (with others) which can be used to estimate structural equation models (open source!)
  • Some packages are loaded permanently (e.g. base), others not (true?)
  • Sometimes there are conflicts between packages (“function is masked”)


  • Central functions
    • install.packages("packagename"): Install package (is downloaded)
      • install.packages("C:/.../crowdflower.tar.gz", repos = NULL, type = "source"): Install package from hardrive
    • library(packagename): Load an installed package
    • detach("package:packagename"): Unload a package
    • remove.packages("packagename"): Unintall package
  • Other functions
    • library(): Display all installed packages
    • library(help=packagename): Describe a package
    • search(): Display all loaded packages
    • ls("package:packagename"): Display all objects within a package
    • packagename::bar: Load just use one object in a package (e.g. a function)