I am trying to run the following code to impute data:
df_imp <- missForest(df)
I get the following error:
Error in sample.int(length(x), size, replace, prob) :
invalid first argument
Why is this happening?
I am trying to run the following code to impute data:
df_imp <- missForest(df)
I get the following error:
Error in sample.int(length(x), size, replace, prob) :
invalid first argument
Why is this happening?
It's difficult to tell what the issue is without seeing a sample or summary of your data. It could be caused by one of your columns being an unexpected data type - I believe missForest expects all numerical columns.
Another potential issue is the format of your df
- is it a data.frame, matrix, tibble? Does this help:
df <- as.data.frame(df)
df_imp <- missForest(df)