I have a big dataframe as 'data', lets consider this:
`data <- data.frame(DATE = c(2012, 2012, 2013, 2014, 2014, 2015),
NAME = c("A", "G", "N", "L",'L' "L"),
LCR = c(1, 3, 5, 4, 5, 1),
MWFR=c(0,0,0,0,0,0,1,1),
reg=c(1,1,0,0,1,1,1,1))
and I want to run a regression but when I run it I get this error:
pdata <- pdata.frame(data, index = c("NAME", "DATE"))
regmodelfix<- plm(LCR ~ MWFR+reg+ MWFR*reg , model ='within',data=pdata, effect = 'twoways')
error :duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting
I realized that I need to make unique name in each rows of NAME and DATE columns so I tried make.names
rownames(data) <- make.names(data$NAME, unique = TRUE)
but it does not work! Any idea?