Max Length for a Vector in R

If you’re willing to work with the development version of R, you can have experimental support for this feature. From http://stat.ethz.ch/R-manual/R-devel/doc/html/NEWS.html :

LONG VECTORS

There are the beginnings of support for vectors longer than
2^31 – 1 elements on 64-bit platforms. This applies to raw, logical, integer,
double, complex and character vectors, as well as lists. (Elements of
character vectors remain limited to 2^31 – 1 bytes.)

All aspects are currently experimental.

What can be done with such vectors is currently somewhat limited,
and most operations will return the error ‘long vectors not supported
yet’. They can be serialized and unserialized, coercion, identical()
and object.size() work and means can be computed. Their lengths can be
get and set by xlength(): calling length() on a long vector will throw
an error.

Most aspects of indexing are available. Generally double-valued
indices can be used to access elements beyond 2^31 – 1.

See the link for more details. I haven’t experimented with this at all myself, so I can’t comment on whether it is practically useful yet or not.

If you go to http://developer.r-project.org/R_svnlog_2011 (and http://developer.r-project.org/R_svnlog_2012) and search for “long vectors” you can get a sense of the work that is going on.

Leave a Comment