[R] 64 bit version for linux and build huge matrix

Marc Schwartz marc_schwartz at me.com
Thu Mar 15 21:37:25 CET 2012

On Mar 15, 2012, at 3:19 PM, Rich Shepard wrote:

> On Fri, 16 Mar 2012, Shengyun Peng wrote:
>> I downloaded R from http://cran.cnr.berkeley.edu/, with the linux version.
>> But after compile, I don't know how to start 64 bit R, as there is only
>> one R executable under bin folder, not alike windows version which have
>> two executables.

Windows and OSX pre-compiled binaries on CRAN are built with both 32 bit and 64 bit executables. Building from source will typically default to your system architecture.

>  If your system has a 64-bit version of the distribution installed then
> that's how applications are built. You start it by typing 'R' (without the
> quotes) on the command line. Linux is not Microsoft.

To verify, use:


If it comes back with 8, you are running 64 bit R.

>> Other than that, I want to build a matrix 65536 rows by 65536 columns, but
>> the system tells me: Error in matrix(0, 65536, 65536) : too many elements
>> specified. So, I want to know if there's anything I can do to achieve that
>> and that's one reason I need 64 bit R.
>  How much memory do you have installed?
> Rich

That won't matter here. R uses signed 32 bit signed integers for indexing and a matrix, more generally an array, is essentially a vector with dimensions. Thus, you can only have (2^31) - 1 elements in a vector/matrix/array and 64k^2 is larger than that...It is the case whether you are running 32 bit or 64 bit R.

> (65536 * 65536) < (2 ^ 31) - 1

There are others here with hands-on experience that can comment, but a starting place to look for potential solutions would be the High Performance Computing Task View (http://cran.r-project.org/web/views/HighPerformanceComputing.html) under "Large memory and out-of-memory data".


Marc Schwartz

More information about the R-help mailing list