簡體   English   中英

如何按索引將ffdf子集化?

[英]How to subset ffdf by index?

我想按索引子集一個ffdf對象,返回另一個ffdf對象。

有關subset.ffdf幫助文件 ,您可以將范圍索引(ri)對象作為參數傳遞,但是當我嘗試執行以下操作時:

data_subset <- subset.ffdf(data, ri(1, 1e5))

我收到此錯誤:

Error in which(eval(e, nl, envir)) : argument to 'which' is not logical

根據You-Leee的建議,我嘗試使用此代碼傳遞感興趣的索引的邏輯向量:

n <- length(data[[1]]) #10.5 million
logical_index = c(1, 1e5) == seq.int(1, n)
data_subset <- subset(data, logical_index)

我嘗試運行兩次,每次我的R-Studio崩潰並顯示消息R encountered a fatal error. The session was terminated. R encountered a fatal error. The session was terminated. 起初我以為這可能是內存限制,但是從我的活動監視器來看,我仍然有8GB可用的4GB。 此外,這也不應該過多地加載到內存中。

該參數必須是邏輯上的,因此您必須在所需的索引上輸入TRUE,否則輸入FALSE:

> data <- ffdf(a = ff(1:12))
> subset.ffdf(data, c(1, 1e5) == seq.int(1, length(data$a)))
ffdf (all open) dim=c(1,1), dimorder=c(1,2) row.names=NULL
ffdf virtual mapping
  PhysicalName VirtualVmode PhysicalVmode  AsIs VirtualIsMatrix     PhysicalIsMatrix
a            a      integer       integer FALSE           FALSE                FALSE
  PhysicalElementNo PhysicalFirstCol PhysicalLastCol PhysicalIsOpen
a                 1                1               1           TRUE
ffdf data
  a
1 1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM