1

I'm trying to impute missing data with the "mi" package in r and I keep getting an error on all my variables

My code: mdf <- missing_data.frame(data.frame)

Error I get:

Error in .guess_type(y, favor_ordered, favor_positive, threshold, variable_name) : age : must be a vector

When I check type:

typeof(data.frame$age)

I get:

[1] "double"

Anyone know the best way to fix this?

  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Oct 28 '19 at 20:20
  • Welcome to StackOverflow. If you could share some sample code, it will help us understand the issue better. – Sandy Oct 28 '19 at 22:25

2 Answers2

1

Turns out it was a tibble and needed to be a data.frame for this function. This worked:

datasetdf <- as.data.frame(dataset)
mdf <- missing_data.frame(datasetdf)
1

I know its too late but I was having the same issue and tried changing it from tibble it still didn't work.

This is what worked: y = as.vector(y)

Thought it might be helpful to someone.