Search code examples
rplyrplm

R: Are there any known issues when plyr/dplyr/data.table and plm packages used together


I have been forming a panel dataset based on many other panel datasets. I have been puzzled by data.table or even base R function merge() that often alter the ordering of rows. So after much trial and error I used the following from plyr:

join(x, y, by=c("Firm", "Index"))

Finally, when I prepared by final panel dataset and used the attach() function and plm package for the analysis, I get the following error:

Error in pdim.default(index[[1]], index[[2]]) when I investigate further using

options(error=recover)

I find

stop(cat("duplicate couples (time-id)\n"))

Kindly suggest what could be wrong and how to fix it?


Solution

  • It seems like in your data (maybe due to the merging process) you have individuals which have the same value in the time index more than once (or more than one NA). You could either look at your data or try table(index(your_pdataframe), useNA = "ifany") to find out which.