I have encountered unexpected behaviour (at least, unexpected by me) when working with the brilliant mi package, for missing data imputation, and tibbles.
Let's assume a tibble called B. The offending command is :-
A <- missing_data.frame(B)
The resulting error message is :-
Error in .guess_type(y, favor_ordered, favor_positive, threshold, variable_name) [[Name of first variable in B]] must be a vector
This example reproduces the behaviour.
# Make the test data frames and tibbles
Numbers <- sample(seq(1:200),40)
Numbers2 <- sample(seq(1:200),40)
Numbers3 <- sample(seq(1:200),40)
Letters <- sample(letters,40,replace=TRUE)
#Mixed numeric and character data
DF.test <- data.frame(Numbers,Letters)
str(DF.test) #Number, Factor
DF.test2 <- data.frame(Numbers,Letters,stringsAsFactors = FALSE)
str(DF.test2) #Number, Character
Tibble.test <- data_frame(Numbers,Letters)
str(Tibble.test) #Number, Character
# Run the tests
DF.mdf <- missing_data.frame(DF.test) # Fine
DF2.mdf <- missing_data.frame(DF.test2) # Fine
Tibble.mdf <- missing_data.frame(Tibble.test) # ERROR
Tibble.mdf <- missing_data.frame(data.frame(Tibble.test)) # Fine
#Purely numeric data
Tibble.test2 <- data_frame(Numbers,Numbers2,Numbers3)
str(Tibble.test2) # Number, Number, Number
# Run the tests
Tibble.mdf2 <- missing_data.frame(Tibble.test2) # ERROR
Tibble.mdf2 <- missing_data.frame(data.frame(Tibble.test2)) # Fine
It seems that mi objects to something in tibbles, but not in dataframes. The error message is unhelpful. It's easy to fix, by coercing the tibble back to a data frame, but I don't see a mention of this issue in the documentation. I am wholly unfamiliar with the innards of mi.
Am I missing something basic, or something in the documentation, or is this genuinely unexpected behaviour? All assistance, comments and interpretations are welcomed.