Answers.Body: <p>Installing packages outside of an R session is arguably the point of using <code>conda</code>.  Package management isn't something that should be done within scripts, only the loading of packages. Doing so ensures that your environment setup is somewhat robust, which should be set before you perform actual calculations.</p>
  
  <p>Using <code>conda install ...</code> is the best way to ensure environment stability here, and, thankfully, lots of people at Bioconductor have worked very hard to make sure <code>bioconda</code> packages fit with the conda framework.</p>
  
  <p>If you need to find packages, you can search online at <a href="https://anaconda.org" rel="nofollow noreferrer">https://anaconda.org</a>, or from the command line via <code>conda search &lt;pkg&gt;</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-12T21:56:12.290Z
Answers.Text: I'm really grateful to everyone creating `conda install`-able packages for R and bioconductor packages. I'm not looking to install packages in R scripts, only in interactive R sessions. It breaks the flow to step out of an R session and install a package. I should also mention that I do break environment stability with my habits, where my default R library is user-level (`~/.Rlibs/`), not environment-level. `.libPaths()[2]` is where the conda R library path sits.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-22T18:08:13.543Z
Answers.Text: Hi, as a follow-up: What would be the recommended way to install packages that are not available in the conda channels? Which of the other options (install.packages() or BiocManager::install() or devtools::install_github()) should be the backup.. Thanks!
Answers.UserDisplayName: Tapper
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-22T19:32:14.013Z
Answers.Text: Conda does handle PyPI packages well, but unfortunately it doesn't handle R packages from CRAN as nicely. Bioconductor packages available through `BiocManager::install` should all be listed with the name `bioconductor-<packagename>` in the `bioconda` channel, but other R packages on CRAN might not be. Personally, I've found that the easiest way to deal with CRAN-only packages is to make my own conda package using `conda skeleton cran <packagename>`, then install your local packge, or upload it to [Anaconda cloud](https://anaconda.org) first before installing
Answers.UserDisplayName: James Hawley
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-12T17:07:57.990Z
Answers.LastActivityDate: 2019-07-12T17:07:57.990Z
Answers.UserDisplayName: James Hawley
Body: <p>I have R installed and managed by conda (miniconda) on my MacBook Pro. The version of R I use most frequently (3.5.1) is installed on the base environment and I have other version-specific environments as well. I did this as it was easier than managing R on homebrew.</p>
  
  <p>The downside I now face is that I cannot use <code>install.packages()</code>, <code>BiocManager::install()</code> or <code>biocLite()</code> to install most packages. <code>devtools::install_github()</code> seems to work fine for the few packages I have installed from GitHub.</p>
  
  <p>I have to use <code>conda install -c [conda-forge|bioconda] [r|bioconductor]-package_name</code> to install my packages and it breaks my workflow and I need to step outside of R to install packages.</p>
  
  <p>Am I doing anything wrong, or is this the only way packages can be managed when R in installed through conda?</p>
  
  <p>A few sample packages that I needed to install using <code>conda</code>:</p>
  
  <ul>
  <li>tidyverse</li>
  <li>tximport</li>
  <li>deseq2</li>
  <li>apeglm</li>
  <li>maftools</li>
  <li>sva</li>
  </ul>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-11T15:11:59.980Z
Comments.Text: A colleague pointed me to this post: https://stackoverflow.com/q/26185978/1394178, and I tried the top 2 solutions. The Mojave solution (that installs a bunch of headers) worked for a package (`refGenome`) where the file `wchar.h` was the problem. Not sure if this would work for every package that runs into a compiler error.
Comments.UserDisplayName: Ram RS
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-12T07:34:08.593Z
Comments.Text: What error message do you get when you try to install those bioconductor packages from R?
Comments.UserDisplayName: llrs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-12T14:14:18.853Z
Comments.Text: It's mostly C/C++ make/compile error messages. It happened so often that I stopped looking at the exact error message. I'll create a new conda env and post exact error messages for these packages.
Comments.UserDisplayName: Ram RS
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-13T14:23:23.860Z
Comments.Text: I tried just with `tidyverse`. Here are the [conda](https://gist.github.com/RamRS/8bb2def4b9d1d8c28017d457e61d6514) and [R](https://gist.github.com/RamRS/9d5040ef4bc7ce6797085c2370ec873a) steps. The error messages in the R step are not complete, as there was only so much scroll-back history I could get to. Probably should have redirected STDERR to a file.
Comments.UserDisplayName: Ram RS
Tags: <r><bioconductor><conda>
Title: Using `install.packages` with conda-managed R
ThreadText: # Using `install.packages` with conda-managed R
  
  (Asked by: username_0 on 2019-07-11)
  
  I have R installed and managed by conda (miniconda) on my MacBook Pro. The version of R I use most frequently (3.5.1) is installed on the base environment and I have other version-specific environments as well. I did this as it was easier than managing R on homebrew.
  
  The downside I now face is that I cannot use `install.packages()`, `BiocManager::install()` or `biocLite()` to install most packages. `devtools::install_github()` seems to work fine for the few packages I have installed from GitHub.
  
  I have to use `conda install -c [conda-forge|bioconda] [r|bioconductor]-package_name` to install my packages and it breaks my workflow and I need to step outside of R to install packages.
  
  Am I doing anything wrong, or is this the only way packages can be managed when R in installed through conda?
  
  A few sample packages that I needed to install using `conda`:
  
  * tidyverse
  * tximport
  * deseq2
  * apeglm
  * maftools
  * sva
  
  **Tags:** r, bioconductor, conda
  
  > **Comments:**
  > **username_0**: A colleague pointed me to this post: https://stackoverflow.com/q/26185978/1394178, and I tried the top 2 solutions. The Mojave solution (that installs a bunch of headers) worked for a package (`refGenome`) where the file `wchar.h` was the problem. Not sure if this would work for every package that runs into a compiler error.  
  > **username_1**: What error message do you get when you try to install those bioconductor packages from R?  
  > **username_0**: It's mostly C/C++ make/compile error messages. It happened so often that I stopped looking at the exact error message. I'll create a new conda env and post exact error messages for these packages.  
  > **username_0**: I tried just with `tidyverse`. Here are the [conda](https://gist.github.com/username_0/8bb2def4b9d1d8c28017d457e61d6514) and [R](https://gist.github.com/username_0/9d5040ef4bc7ce6797085c2370ec873a) steps. The error messages in the R step are not complete, as there was only so much scroll-back history I could get to. Probably should have redirected STDERR to a file.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-07-12. Score: 3
  
  Installing packages outside of an R session is arguably the point of using `conda`. Package management isn't something that should be done within scripts, only the loading of packages. Doing so ensures that your environment setup is somewhat robust, which should be set before you perform actual calculations.
  
  Using `conda install ...` is the best way to ensure environment stability here, and, thankfully, lots of people at Bioconductor have worked very hard to make sure `bioconda` packages fit with the conda framework.
  
  If you need to find packages, you can search online at <https://anaconda.org>, or from the command line via `conda search <pkg>`.
  
  > **Comments:**
  > **username_0**: I'm really grateful to everyone creating `conda install`-able packages for R and bioconductor packages. I'm not looking to install packages in R scripts, only in interactive R sessions. It breaks the flow to step out of an R session and install a package. I should also mention that I do break environment stability with my habits, where my default R library is user-level (`~/.Rlibs/`), not environment-level. `.libPaths()[2]` is where the conda R library path sits.  
  > **username_3**: Hi, as a follow-up: What would be the recommended way to install packages that are not available in the conda channels? Which of the other options (install.packages() or BiocManager::install() or devtools::install_github()) should be the backup.. Thanks!  
  > **username_2**: Conda does handle PyPI packages well, but unfortunately it doesn't handle R packages from CRAN as nicely. Bioconductor packages available through `BiocManager::install` should all be listed with the name `bioconductor-<packagename>` in the `bioconda` channel, but other R packages on CRAN might not be. Personally, I've found that the easiest way to deal with CRAN-only packages is to make my own conda package using `conda skeleton cran <packagename>`, then install your local packge, or upload it to [Anaconda cloud](https://anaconda.org) first before installing  
  
  ---
  
  