Skip to content

Create packages

For languages such as R, Python, and Julia, it is generally a good idea to write your code as a package/library. This can make it easier to install and run your code on a new computer, on a high-performance computing platform, and for others to use on their own computers.

Info

This is a simple process and entirely separate from publishing your package or making it publicly available.

It also means you can avoid using source() in R, or adding directories to sys.path in Python.

To create a package you need to provide some necessary information, such as a package name, and the list of the packages that your code depends on ("dependencies"). You can then use packaging tools to verify that you've correctly identified these dependencies and that your package can be successfully installed and used!

This is an important step towards ensuring your work is reproducible.

There are some great online resources that can help you get started. We list here some widely-recommended resources for specific languages.

Writing R packages

For R, see R Packages (2nd ed) and the devtools package.

Other useful references include:

Info

rOpenSci offers peer review of statistical software.

Writing Python packages

The Python Packaging User Guide provides a tutorial on Packaging Python Projects.

Other useful references include:

Info

pyOpenSci offers peer review of scientific software

Writing Julia Packages

The Julia's package manager documentation provides a guide to Creating Packages