Installing MortalityLaws

Marius D. Pascariu

2026-05-05

The MortalityLaws package can be installed from either CRAN (the official R package repository) or GitHub (the development version). Most users will prefer the first option, as it provides a stable, tested release. The sections below explain both approaches.

Install the stable version from CRAN

The easiest way to get MortalityLaws is to install it from CRAN. This gives you the most recent stable release that has passed R’s quality checks.

  1. Make sure you have a recent version of R (≥ 3.5 is recommended). You can check your R version at the console:

    R.version.string
  2. Install the package by running the following command in your R console:

    install.packages("MortalityLaws")

    This will automatically download and install the package along with its required dependencies.

  3. Load the package and verify that it works:

    library(MortalityLaws)
    help(package = "MortalityLaws")

Install the development version from GitHub

If you want to try the latest features, bug fixes, or contribute to the development of MortalityLaws, you can install the development version directly from GitHub. This version may contain changes that have not yet been submitted to CRAN.

Step 1: Install devtools

The devtools package provides the install_github() function needed to fetch and install packages from GitHub. Install it from CRAN:

install.packages("devtools")

What devtools does: It automates the process of downloading source code from GitHub, resolving dependencies, compiling (if needed), and installing the package into your R library.

Step 2: Set up a development environment

To install packages from source (which is what GitHub packages are), your system needs a compiler and associated tools:

Why is this needed? Unlike CRAN binaries (pre-compiled), GitHub packages are distributed as source code. R must compile them locally, which requires a development toolchain.

Step 3: Install MortalityLaws from GitHub

Once devtools is installed and your development environment is ready, run:

devtools::install_github("mpascariu/MortalityLaws")

This command: 1. Clones the repository from https://github.com/mpascariu/MortalityLaws. 2. Builds the package from source. 3. Installs it into your R library.

Step 4: Verify the installation

After installation, load the package and check that everything works:

library(MortalityLaws)
availableLaws()   # list all implemented mortality laws

Updating an existing installation


You are now ready to use MortalityLaws! Happy modelling.

For further guidance, check the other vignettes (e.g., the introductory vignette) and the help pages:

browseVignettes("MortalityLaws")   # view available vignettes
?MortalityLaw                       # help for the main fitting function

References