Reputation: 1892
I'm attempting to aggregate a data frame and am getting an error I do not understand. I have a data frame called M15 that is 200k+ records of 33 variables. I cannot reproduce this error using data that I can share with the community.
M15<-M15backup[c(600:700),]
# setting the fields to roll up
aggField<-c('Location','EEStatus')
# group by rest of fields
byField<-setdiff(x=colnames(M15),y=aggField)
# example uses built in function, my production code uses a custom
M15.2<-aggregate(x=M15[aggField],
by=M15[byField],
FUN=length
)
If I adjust the 600:700 in the first line I can get the script to run on small blocks of the data frame but if I run for the entire data frame I get an error of the form:
Error in `[[<-.data.frame`(`*tmp*`, len + i, value = c("All Locations", :
replacement has 341 rows, data has 394
Can somebody explain what this error means and/or suggest a way to deal with it?
Upvotes: 4
Views: 5655
Reputation: 4761
This is apparently a bug with R before versions 3.0.3 as per this bug report. I had the same issue and upgraded R to version 3.1.2 and problem went away.
Upvotes: 4