2013-02-14 20 views
0

有沒有辦法將ffdf轉換成正常的數據幀? 假設東西足夠小,以適應公羊。從ffdf到正常數據幀

例如:

library(ff) 
library(ffbase) 

data(trees) 
Girth <- ff(trees$Girth) 
Height <- ff(trees$Height) 
Volume <- ff(trees$Volume) 
aktiv <- ff(as.factor(sample(0:1,31,replace=T))) 
#Create data frame with some added parameters. 
data <- ffdf(Girth=Girth,Height=Height,Volume=Volume,aktiv=aktiv) 
rm(Girth,Height,Volume,trees,aktiv) 

aktiv <- subset.ffdf(data, data$aktiv== "1") 

,然後轉換到活躍的數據幀,並保存RDATA (可悲的是等待輸出不想學習如何與FF包工作的人,所以我有沒有的choise)

感謝

+1

你從哪裏得到的'subset.ffdf'功能?它似乎不在'ff'包中。 – 2013-02-14 12:49:50

+0

你嘗試過'as.data.frame(aktiv)'嗎? – Arun 2013-02-14 12:52:54

+0

參見http://r.789695.n4.nabble.com/how-to-work-with-big-matrices-and-the-ff-package-td1838571.html – 2013-02-14 12:55:37

回答

3

只需使用as.data.frame

aktiv <- subset(as.data.frame(data), aktiv == 1) 

    Girth Height Volume aktiv 
2 8.6  65 10.3  1 
7 11.0  66 15.6  1 
9 11.1  80 22.6  1 
12 11.4  76 21.0  1 
13 11.4  76 21.4  1 
15 12.0  75 19.1  1 
17 12.9  85 33.8  1 
20 13.8  64 24.9  1 
21 14.0  78 34.5  1 
23 14.5  74 36.3  1 
26 17.3  81 55.4  1 
27 17.5  82 55.7  1 
28 17.9  80 58.3  1 
31 20.6  87 77.0  1 

從這裏你可以很容易地使用savewrite.csv,例如:

save(aktiv, file="aktiv.RData") 
+0

感謝快速的答案,我不知道爲什麼我沒有試過:) – Soly 2013-02-14 13:01:59

+0

隨時接受答案,如果它是準確的 – statquant 2013-02-14 13:50:34