R中向量的最大长度 [英] Max Length for a Vector in R

查看:41
本文介绍了R中向量的最大长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 R 'Memory-limits' 文档,不可能分配长度超过 2^31-1 的向量.这是因为用作索引的整数只能使用 31 位(符号一位).但是在 64 位系统上,我应该能够分配更长的向量.为什么 R 在 64 位系统上强加相同的最大长度?有没有办法绕过限制?

According to the R 'Memory-limits' documentation, it isn't possible to allocate a vector of length longer than 2^31-1. This is because the integer used as an index can only use 31 bits (one bit for the sign). But on a 64-bit system, I should be able to allocate longer vectors. Why does R impose this same max length on 64-bit systems? Is there a way to circumvent the limit?

推荐答案

如果您愿意使用 R 的开发版本,您可以获得对该功能的实验性支持.来自 http://stat.ethz.ch/R-manual/R-devel/doc/html/NEWS.html :

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 :

长向量

开始支持向量的时间超过2^31 - 64 位平台上的 1 个元素.这适用于原始、逻辑、整数、双向量、复向量和字符向量,以及列表.(要点字符向量仍然限制为 2^31 - 1 个字节.)

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.

目前可以用这些向量做什么有点有限,并且大多数操作将返回错误不支持长向量"然而'.它们可以被序列化和反序列化,强制,相同()和 object.size() 工作和手段可以计算.它们的长度可以是通过 xlength() 获取和设置:在长向量上调用 length() 将抛出一个错误.

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.

索引的大多数方面都可用.一般双值索引可用于访问超过 2^31 - 1 的元素.

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.

如果您访问 http://developer.r-project.org/R_svnlog_2011(和 http://developer.r-project.org/R_svnlog_2012)并搜索长向量",您可以了解正在进行中.

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.

这篇关于R中向量的最大长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆