expand.grid中的奇怪错误()

bre*_*ews 7 r

我创建和评估调用expand.grid使用 eval(parse(...)).

简而言之:

len <- 36
Text <- paste("pos <- expand.grid(",
  paste(rep("c(TRUE,FALSE)", len), collapse=","), ")", sep="")
eval(parse(text = Text))
Run Code Online (Sandbox Code Playgroud)

给我

Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) : 
invalid 'times' value
In addition: Warning message:
In rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :
NAs introduced by coercion
Run Code Online (Sandbox Code Playgroud)

而不是变量lenTRUE/ 的组合数.FALSEpos

我忽略了一些简单的事情,或者可能不是......?

Jos*_*ich 10

正如我在评论中所说,这与eval或无关parse.错误在于expand.grid.问题是R的最大向量长度是2 ^ 31-1并且rep.int正在尝试创建2 ^ 36长度向量.