1

我正在使用dcast函数来 rshape 中的 datframe R,但同时使用大型数据框。我将其转换为ffdf dataframe无法使用的dcast功能,如果有其他选择,请帮助我。找到我用于小型数据框的以下示例以及我想要做什么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

4

1 回答 1

0

我得到了这个问题的答案,但它可能无法在很大程度上分解数据

# 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

于 2014-12-22T10:05:41.503 回答