How to ensure specific versions of python modules installations when using `reticulate::conda_install()`?

Organizing my work in distinct R projects, how can I use reticulate::conda_install() to install specific versions of python modules on a per-project basis?

Setting up reticulate, I have followed tips from this blog post. Namely, using reticulate::conda_create() and reticulate::conda_install() within the directory of the R project I'm working on.

However, for the sake of reproducibility, I want to account for the versions of python packages installed this way. How can I do so? According to the function's reference page, there's no function parameter to specify the version of the required python module being installed. Thus, if I run the same script a year from now, how could I guarantee that conda_install() would install the same versions of the python modules as installed today?

You can specify the version in the packages argument. From the documentation:

packages

A character vector, indicating package names which should be installed or removed. Use python=<version> to request the installation of a specific version of Python.

@andresrcs , thanks. I'm not sure I follow, could you please provide a code snippet as example?

The packages argument is a character vector of desired packages we wish to install using conda_install().
For example I could do:

py_packages <- c("scikit-learn",  "pandas")

reticulate::conda_install(
    packages = py_packages,
    envname = python_virtual_env_name_as_path
)

How can I specify which version of pandas and which version of scikit-learn to install?

For example: packages = c("numpy==1.8.0")

Edit: Since the package documentation mentions python instead of "python package" by mistake, I have made a pull request on github to correct this so future versions (or currently the development version) have a clearer explanation. The new text says:

packages

A character vector, indicating package names which should be installed or removed. Use <package>==<version> to request the installation of a specific version of a package.