[R] Decast

Val valkremk at gmail.com
Sat Nov 14 02:34:37 CET 2015


Hi all,
I have a data frame called "df"  it's dimension is

dim(df)
[1] 9540634       38

>From this data frame  the  variable *  df$X1 *has about 78, 000 unique
values and  *df$region *has two classes.  I am trying to do  the following
operation
The goal is reshaping the variable from  long to wide

#############################
library(reshape)
library(reshape2)
library(plyr)

sf1 <- ddply(df, df("df$X1","df$region"), summarise,
                           N    = length(df$region))
xr  <- dcast(sf1, df$x1 ~  df$region,  value.var= "N")


With this huge data set it is taking more than 6 hours and I don't know
when it is finishing.

I am sure the above syntax does not have any error because I tested with
small data set and worked fine except the following message
Aggregation function missing: defaulting to length

Is there an alternative way of doing this operation that may not take long
hours.
Thank you in advance

	[[alternative HTML version deleted]]



More information about the R-help mailing list