I am trying to convert an imputed data frame into a mids object using as.mids
. There are 5 imputations and the original dataset. It is a long format data frame with 4 waves of BMI measurements and ~11,000 participants. When I run:
mids <- as.mids(df)
I get the following error messages:
'Error in [<- data.frame(*tmp*, j, value = c(X, Y, : replacement has X rows, data has Y'
'Error in .rowNamesDF<-(X, value = value) : duplicate 'row.names' are not allowed'
To correct the latter problem, I tried the code:
colnames(df)[colnames(df)==".id"] <- "id"
This gets rid of the error regarding duplicate row names when I run the as.mids again. I am not sure whether this is changing things that I shouldn't be changing, however.
I have not figured out how to solve the first error.
Can anyone help with sorting this?
I have used as.mids
before and it has worked - I can't figure out what is different about this case.
Thanks!