如何解决R软件包安装中的内存问题

时间:2019-06-20 13:43:56

标签: r r-package

我在尝试通过添加其他数据来升级数据包时遇到错误。问题是我遇到内存错误。我确信其他人已经制作了具有更大数据集的软件包。人们如何解决这个问题?

==> R CMD INSTALL --no-multiarch --with-keep.source cfsales

* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘cfsales’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
Error in lazyLoadDBinsertVariable(vars[i], from, datafile, ascii, compress,  : 
  long vectors not supported yet: connections.c:5984
ERROR: lazydata failed for package ‘cfsales’
* removing ‘/usr/local/lib/R/site-library/cfsales’
Warning in q("no", status = status, runLast = FALSE) :
  system call failed: Cannot allocate memory

以下是我的数据目录中内容的列表以及以MB为单位的文件大小。

total 188M
-rw-rw-r-- 1 ahallam ahallam   1M Jun 17 20:18 holidays_events.rda
-rw-rw-r-- 1 ahallam ahallam   1M Jun 17 20:18 items.rda
-rw-rw-r-- 1 ahallam ahallam   1M Jun 17 20:18 oil.rda
-rw-rw-r-- 1 ahallam ahallam   1M Jun 20 08:51 store_day_sales.rda
-rw-rw-r-- 1 ahallam ahallam   1M Jun 17 20:18 stores.rda
-rw-rw-r-- 1 ahallam ahallam   2M Jun 19 17:23 test.rda
-rw-rw-r-- 1 ahallam ahallam 185M Jun 19 17:36 train.rda
-rw-rw-r-- 1 ahallam ahallam   1M Jun 17 20:18 transactions.rda

这是我的sessionInfo

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] cfsales_0.0.0.9000

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1       clisymbols_1.2.0 packrat_0.5.0    crayon_1.3.4     withr_2.1.2      rprojroot_1.3-2  assertthat_0.2.1 R6_2.4.0        
 [9] backports_1.1.4  git2r_0.25.2     magrittr_1.5     rlang_0.3.4      rstudioapi_0.10  fs_1.3.1         testthat_2.1.1   desc_1.2.0      
[17] tools_3.6.0      glue_1.3.1       pkgload_1.0.2    compiler_3.6.0   usethis_1.5.0

1 个答案:

答案 0 :(得分:0)

如评论中所述,消息

  

尚不支持长向量:connections.c:5984

是可疑的。看着that line,我们看到了

inlen = LENGTH(in);

其中LENGTH(与XLENGTH相反)不支持long vectors,即具有多于2^31 - 1个元素的向量。以某种形式,您的数据文件由比此更长的向量表示。