r - Error message while converting 2.1 mil rows from long to wide format -


i have been battling code day trying convert data long wide format. let me explain data set , code used.

i have on 2 million rows 700k unique subject(usb), 125 unique days(date, m-d-y format), 83 unique group (grp), kyc , val1.

here last code looks based on solution found on stackoverflow:

n1 = unique(mydata[,c("usb","date")])  n1$idv = 1:nrow(n1)  n2=merge(mydata,n1)  dcast(n2,usb + idv ~ grp, value.var="val1"). 

this worked small portion of data other failed whole data set.

i noticed

unique(mydata[,c("usb","date","kyc")]) 

works better small sample , genesis of problem.

for privacy reason can not post portion of data.

please appreciate suggestion or how fix this.

below other examples here have tried no luck

library(splitstackshape)  out_df <- dcast( getanid( x_df, 'time' ), time~.id, value.var='measure' )  qcc( out_df[,-1], type = 'xbar', labels = out_df[,1] ) 

i tried :

library(reshape2) library(plyr)  # add variable how many times id*cat combination has occured  tmp <- ddply(df2, .(id, cat), transform, newid = paste(id, seq_along(cat)))  # aggregate using newid , toss in id don't lose out <- dcast(tmp, id + newid ~ cat, value.var = "val") 

likewise this:

my.df$cycle <- rep(1:2, each=num.id*num.time)  dcast(melt(my.df, id.vars=c("cycle", "id", "time")), cycle+id~variable+time) 

and other suggests.

i implement on small subset of data set, when tried run entire data set error message.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -