R 为什么我经常收到这个“;无法分配内存”;错误?

R 为什么我经常收到这个“;无法分配内存”;错误?,r,R,我试图解决一个问题,从一个包含两个变量(项目ID和用户ID)的数据帧生成一个交叉表。我试图从一个数据帧生成一个交叉表。交叉表将被用来寻找用户和文章的中心度。我有这样的数据框 article user 1 u1 1 u2 1 u3 2 u2 2 u4 2 u5 3 u1 3 u6 3 u4 3 u7 这只是一个例子

我试图解决一个问题,从一个包含两个变量(项目ID和用户ID)的数据帧生成一个交叉表。我试图从一个数据帧生成一个交叉表。交叉表将被用来寻找用户和文章的中心度。我有这样的数据框

article  user

  1        u1
  1        u2
  1        u3
  2        u2
  2        u4
  2        u5
  3        u1
  3        u6
  3        u4
  3        u7
这只是一个例子,我有维度的dataframe

dim(x)   
[1] 364323      2
当我将代码应用到数据帧时,它会给我一个错误,如

n<-(table(y)>0)*1 ##Error: cannot allocate vector of size 2.4 Gb
附加警告

Error: cannot allocate vector of size 12.9 Gb

In addition: Warning messages:

1: In matrix(0L, nc = n.u, nr = n.u) :

  Reached total allocation of 4078Mb: see help(memory.size)

2: In matrix(0L, nc = n.u, nr = n.u) :
  Reached total allocation of 4078Mb: see help(memory.size)

3: In matrix(0L, nc = n.u, nr = n.u) :

  Reached total allocation of 4078Mb: see help(memory.size)


4: In matrix(0L, nc = n.u, nr = n.u) :

  Reached total allocation of 4078Mb: see help(memory.size)

非常感谢您的帮助

好吧,您可以很容易地计算出这张桌子将有多大。如果你有很多文章和很多用户,这对你的内存来说太大了。@Roland我怎样才能克服这个问题?你的操作系统上有多少RAM,以及
memory.limit()
告诉你什么?买更多的RAM?说真的,你甚至都没有告诉我们你想要实现什么。这使得建议替代方案变得很困难。@Roland,这可以通过增加
内存.limit()
来解决。也许他已经有足够的内存了
Error: cannot allocate vector of size 12.9 Gb

In addition: Warning messages:

1: In matrix(0L, nc = n.u, nr = n.u) :

  Reached total allocation of 4078Mb: see help(memory.size)

2: In matrix(0L, nc = n.u, nr = n.u) :
  Reached total allocation of 4078Mb: see help(memory.size)

3: In matrix(0L, nc = n.u, nr = n.u) :

  Reached total allocation of 4078Mb: see help(memory.size)


4: In matrix(0L, nc = n.u, nr = n.u) :

  Reached total allocation of 4078Mb: see help(memory.size)