简体   繁体   中英

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

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 ?

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().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM