Hi @Shakri! Welcome!
It's hard for me to be certain what's causing that error the code above doesn't include enough information for me to be able to run it myself (this is pretty common — when you're new to this stuff, it's hard to know how much information is enough!). The best thing would be if you can make your question into a reproducible example (follow the link for instructions and explanations).
That said, here's an educated guess about what might be wrong:
First, I'm going to guess that you're running the
plm function from the
plm package (there is more than one function out there named
Looking at the source code for
plm::plm(), it includes the following lines where it tries to preserve the row names from the original data frame that was passed in, after having changed them with some intervening steps:
(line 358 of est_plm.R)
orig_rownames <- row.names(data)
(lines 382-387 of est_plm.R)
# preserve original row.names for data [also fancy rownames]; so functions
# like pmodel.response(), model.frame(), model.matrix(), residuals() return
# the original row.names eval(mf, parent.frame()) returns row.names as
# character vector containing the "row_number" with incomplete observations
row.names(data) <- orig_rownames[as.numeric(row.names(data))]
In R, row names are an attribute of a data frame. They are supposed to be unique, but there are various ways that you can wind up with non-unique row names (see this post for a deep dive on row name quirks). My guess is that something about the row names in your initial data frame is causing the above procedure to fail.
To see if my guess is on the right track, you could try resetting your data frame's row names to the automatic defaults, then running the model code again:
MDF.p2 <- MDF.p
row.names(MDF.p2) <- NULL
fixeffect2 <- plm(Income ~ Tassets, data = MDF.p2, model = "within")
Does that work? Of course, this won't help if the row names are meaningful and you need to keep them, but perhaps it's a start.
It's going to be hard to help much more without a reproducible example, so I encourage you to give making one a try!