decompr v2

2 minute read

We are happy to announce the release of version two of the decompr package, which includes several important changes that improve usability.

The most important change in the way data is loaded by either the decomp function, or the underlying load_tables_vectors (previously called load_tables), this change is descibed in detail below.

In addition to this, a new minimalist dataset has been bundled, in order to introduce the user to the data format as well as the difference between the two decomposition methods.

Finally, several performance improvements as well as various other small changes have been included.

Input Format Changes

In version 2 of decompr the input method for decompr has been slightly revised. This addresses the problem of the double header used in the old input format, which required the data to be loaded with stringsAsFactors=FALSE. The new input format requires the elements to be provided seperately. The elements required are:

  • intermediate demand
  • final demand
  • country names
  • industry names
  • final output

Although loading the data is somewhat more work, it is much less cumbersome and therefore error prone.

A fallback mode has been implemented in order to facilitate a smooth transition. However, a warning message will be displayed, reminding the user to update the code.


Version 2 contains the following functions.

  • load_tables_vectors
  • leontief
  • wwz
  • decomp

The process of setting up the various data structures (load_tables_vectors) for the decomposition together with the subsequent decomposition (wwz or leontief) can be rather resource / time consuming. For this reason we have chosen to implement these steps as seperate functions, so that the process can be split up into two steps.

In addtion to this, a wrapper function (decomp) is also provided which combines the two, thus also providing the user with option to run both steps at the same time.

Finally, the deprecated load_tables is also provided, in order to facilitate the transition process from version 1 of the decompr package. This function will be dropped in the next release, please update your code to use the new input format.


Install the latest stable version from cran.


Now that the package is installed, we can proceed with loading the application and opening the help file for information.

# load the package
If you use decompr for data analysis,
please cite R as well as decompr,
using citation() and citation("decompr") respectively.
# open the help file

We can now load the leather data set and explore what object are contains in this data set.

# load the data set

# explore the content
[1] "countries"  "final"      "industries" "inter"      "out"

The Wang-Wei-Zhu decomposition is the default method for the decomp function, which means we can call the function without specifying a method.

# use the direct approach
# run the WWZ decomposition
wwz <- decomp(inter,
              out        )