Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between install a r package with conda and with install.packages()?

Tags:

r

conda

I usually install the r-packages with install.library (), but now I am starting to use conda and in its documentation it shows me the packages from r can be installed with: conda install -c r package-name. What's is tha difference with install.packages("package-name")?

And conda install -c r package-name is simillary at conda install package-name?

like image 387
Marco Avatar asked Sep 15 '25 11:09

Marco


1 Answers

If you want to use conda to manage R package dependencies, you should install R packages via conda rather than install.packages(). If you use install.packages(), the package will be installed in conda's library path, but conda won't be tracking it.

This is problematic. For example, if you want to share your environment with someone else. In this case, you would create environment.yml, but it would be missing the R packages installed via install.packages().

I just tested this out myself through the following steps:

conda create --name new_env
conda activate new_env 
conda install r-base=4.0.0  
#install randomForest via install.packages()    
conda env export > test_environment.yml

I'm sure one can enumerate other reasons to use conda although sometimes one has no choice but to use install.packages(). This is only one reason to prefer installing via conda and not install.packages().

like image 166
Daniel Conn Avatar answered Sep 17 '25 01:09

Daniel Conn