1

In RStudio there's a Tools menu which allows you to select an installed version/architecture of R under Global Options.

enter image description here

That's great, but my issue with that is that, as the name implies, it is a Global option, so once you select a different architecture (or version number) you then have to restart RStudio and it applies to all of your RStudio instances and projects.

This is a problem for me because:

  • I have some scripts within a given project that strictly require 32-bit R due to the fact that they're interfacing with 32-bit databases, such as Hortonworks' Hadoop
  • I have other scripts within the same project which strictly require 64-bit R, due to (a) availability of certain packages and (b) memory limits being prohibitively small in 32-bit R on my OS

which we can call "Issue #1" and it's also a problem because I have certain projects which require a specific architecture, though all the scripts within the project use the same architecture (which should theoretically be an easier to solve problem that we can call "Issue #2").

If we can solve Issue #1 then Issue #2 is solved as well. If we can solve Issue #2 I'll still be better off, even if Issue #1 is unsolved.

I'm basically asking if anyone has a hack, work-around, or better workflow to address this need for frequently switching architectures and/or needing to run different architectures in different R/RStudio sessions simultaneously for different projects on a regular basis.

I know that this functionality would probably represent a feature request for RStudio and if this question is not appropriate for StackOverflow for that reason then let me know and I'll delete it. I just figured that a lot of other people probably have this issue, so maybe someone has found a work-around/hack?

Hack-R
  • 22,422
  • 14
  • 75
  • 131

1 Answers1

4

There's no simple way to do this, but there are some workarounds. One you might consider is launching the correct bit-flavor of R from the current bit-flavor of R via system2 invoking Rscript.exe, e.g. (untested code):

source32 <- function(file) {
  system2("C:\\Program Files\\R\\R-3.1.0\\bin\\i386\\Rscript.exe", normalizePath(file)) 
}
...
# Run a 64 bit script
source("my64.R")

# Run a 32 bit script
source32("my32.R")

Of course that doesn't really give you a 32 bit interactive session so much as the ability to run code as 32 bit.

One other tip: If you hold down CTRL while launching RStudio, you can pick the R flavor and bitness to launch on startup. This will save you some time if you're switching a lot.

Jonathan
  • 8,497
  • 41
  • 35
  • Thank you, @Jonathan. I agree that there is probably no simple solution, so I will accept this as the solution with +1. Cheers! – Hack-R Sep 16 '14 at 12:59