Disclosure: Though not the case when I first answered this, I am now part of the Conda Forge R team. However, this is volunteer work - I receive no compensation for my work there nor whether you follow the advice in this answer.
Use Conda Forge
Five years out from the original question, I'd assert that a more contemporary solution would simply be: use Conda Forge. The Conda Forge channel not only provides broader coverage of CRAN, but also has a simple procedure and great turnaround time (typically under 24 hours) for adding a missing CRAN package to the channel.
Start from Conda Forge
I'd recommend using Conda Forge for the full stack, and use a dedicated environment for each R version you require.
conda create -n r41 -c conda-forge r-base=4.1 r-irkernel ...
where ...
is whatever additional packages you require (like r-tidyverse
). The r-irkernel
package is optional, but included here because OP mentions using R in Jupyter.
If your environment with Jupyter (which should be in a separate environment) also has nb_conda_kernels
installed, then this environment will automatically be discovered by Jupyter.
Install from Conda Forge
Generally, all R packages on CRAN have an r-
prefixed to the package name on Conda Forge, and the package name is converted to lowercase. So, if your package of interest is PkgName
, first try
conda install -n r41 -c conda-forge r-pkgname
If the package is not available, then proceed to either add it or request it.
Submit a CRAN package with Conda R Skeleton Helper
There is a helpful script collection, called conda_r_skeleton_helper for creating new Conda Forge recipes for CRAN packages. There are clear directions in the README.
In broad strokes, one will
- clone the
conda_r_skeleton_helper
repository
- edit the
packages.txt
file to include r-pkgname
- run the script to generate the recipe
- fork and clone the
conda-forge/staged-recipes
- copy the new recipe folder to the
stage-recipes/recipes
folder
- commit changes, push to the fork, then submit a Pull Request back to Conda Forge
This takes maybe ~15 mins of work. Once submitted, most packages take under 24 hours to get accepted, feedstocked, and deployed to the Conda Forge channel. Once the feedstock is up and running, the Conda Forge infrastructure uses a bot to auto-detect version updates, generate new pull requests, and even auto-merge Pull Requests that successfully build. That is, maintainers have a very minimal workload, and if there are issues, a team is available to help out.
Automation
Personally, I have all this scripted (see scripts). I have a copy of these scripts in the root of a local copy of my staged-recipes
fork. From a shell, I run:
sh new-cran-pkg.sh r-foo
and it:
- Synchronizes my
staged-recipes
main branch to upstream (conda-forge
).
- Creates a new branch for
r-foo
.
- Runs the latest copy of
conda_r_skeleton_helper
for the package (here r-foo
).
- Adds, commits, and pushes the recipe to my fork.
I then just have to visit GitHub to set up the Pull Request. Takes less than a minute.
Ask for help
If you have issues with submitting a recipe or updating an existing one, please ping me in a GitHub Issue or Pull Request (@mfansler
).
File a Package Request
For users uncomfortable with creating and maintaining a Conda Forge build, packages can be requested on Conda Forge's staged-recipes
repository by filing a new Issue. There is a template for Package Request, that includes some information fields to be filled in.