[英]Reshape ffdf dataframe in R
我正在使用dcast
函數在R
rshape datframe,但同時使用大數據框。 我將其轉換為無法使用dcast
功能的ffdf dataframe
,如果有其他選擇,請幫助我。 查找下面的示例,該示例用於小型數據ffdf dataframe
以及我想對ffdf dataframe
執行的ffdf dataframe
:
- hdsample <- read.csv("C:/Users/PK5016573/Desktop/hdsample.csv")
- View(hdsample)
hd<-dcast(hhpsample,MemberID~Year+Specialty+ProcedureGroup+Vendor+PlaceSvc+PCP+PrimaryConditionGroup+CharlsonIndex)
這是可行的,但是:
hhp<-read.ffdf("C:/Users/PK5016573/Desktop/hdsample.csv")
hd<-dcast(hhpsample,MemberID~Year+Specialty+ProcedureGroup+Vendor+PlaceSvc+PCP+PrimaryConditionGroup+CharlsonIndex)
這給我錯誤請幫助
在此先感謝Pavan kancharala
我得到了這個問題的答案,但它可能無法在很大程度上分解數據
# Reshape_function to process on data
# Reshaping data as per year and Primary condition group
library(reshape2)
library(ffbase)
reshapefunction<-function(x){
df=dcast(x,MemberID~ Year+PrimaryConditionGroup,
value.var= "rep.x..each...2668990.",
fun.aggregate = sum)
}
# Reshaping data using reshape_function
# Specifying size of chunks to process the data
PrimaryConditionGroup<-ffdfdply(x=hhp,split=hhp$MemberID
,FUN = function(x) reshapefunction(x),BATCHBYTES = 100000000,trace=TRUE)
View(PrimaryConditionGroup)
所有數據均來自kaggle競賽,又增加了一列“ rep.x..each ... 2668990”。 每行包含1個用於聚合目的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.