我一定是遗漏了一些显而易见的东西:
library(Rmpfr)
list.mpfr <- list(mpfr(10, 128), mpfr(20, 128)) # I'd like to turn this into mpfr(c(10, 20), 128)
test <- c(list.mpfr, recursive=TRUE) # Doesn't work -- should it?
identical(test, list.mpfr) # False -- test is a list of mpfr1 and no longer a list of mpfr
## I'd expect c.mpfr(..., recursive=TRUE) to do the equivalent of c(list(1:5, 8:10), recursive=TRUE)
getAnywhere(c.mpfr)我有一个函数,返回长度为1的mpfr。在上面的示例中,我使用mapply(..., simplify=FALSE)构建了类似于list.mpfr的内容。我希望将长度-1 mpfr对象组合成单个mpfr对象(例如,我可以调用which.max )。
发布于 2013-12-19 22:34:50
找到了解决办法:
library(Rmpfr)
list.mpfr <- list(mpfr(10, 128), mpfr(20, 128))
desired <- new("mpfr", unlist(list.mpfr))
identical(desired, mpfr(c(10, 20), 128)) # Truehttps://stackoverflow.com/questions/20665553
复制相似问题