我有一个~2,000x20,000的数据,我如何在速度和内存方面有效地转换data.table()为matrix高效?
我试过m = as.matrix(dt)但很多警告需要很长时间.df = data.frame(dt)需要很长时间并导致达到内存限制.
有没有有效的方法来做到这一点?或者,只是data.table中的一个函数,它返回dt矩阵形式(根据需要使用glmnet包输入统计模型)?
简单地包装到as.matrix会给我以下错误:
x = as.matrix(dt)
Error: cannot allocate vector of size 2.9 Gb
In addition: Warning messages:
1: In unlist(X, recursive = FALSE, use.names = FALSE) : Reached total allocation of 8131Mb: see help(memory.size)
2: In unlist(X, recursive = FALSE, use.names = FALSE) : Reached total allocation of 8131Mb: see help(memory.size)
3: In unlist(X, recursive = FALSE, use.names = FALSE) : Reached …Run Code Online (Sandbox Code Playgroud)