TesM
TesM

Reputation: 1

Error with as.mids in R: Error in sample.int(length(x), size, replace, prob) : cannot take a sample larger than the population when 'replace = FALSE'

I generated 25 imputed datasets using mice in R. Because I want to add variables and make subsets after imputation, I convert the mids object to a long format:

long1 <- complete(imp, action='long', include=TRUE)

This generates no errors.

Hereafter, I want to convert the long format back to a mids object with this code:

imp<-as.mids(long1)

However, when running this line of code I get this error:

**Error in sample.int(length(x), size, replace, prob) : 
  cannot take a sample larger than the population when 'replace = FALSE'**

Can someone tell me what the error means and how to solve it? I have used as.mids many times in the past and never experienced trouble with it.

Upvotes: 0

Views: 459

Answers (0)

Related Questions