Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix columns in data frame generate error in missRanger #27

Closed
saudiwin opened this issue Mar 23, 2021 · 1 comment
Closed

Matrix columns in data frame generate error in missRanger #27

saudiwin opened this issue Mar 23, 2021 · 1 comment

Comments

@saudiwin
Copy link

Hi -

I've been a big fan/user of this package for a while, so I thought I would contribute a bug report on an issue I just encountered. Essentially, if one of the columns in a data frame is not a vector, the code will error without explanation because the column names don't transfer into a matrix of missing values (dataNA). It appears to happen at this line of code:

dataNA <- is.na(data[, visitSeq, drop = FALSE])

Some reproducible code is below:

# reproducible example

library(missRanger)

irisWithNA <- generateNA(iris, seed = 34)

# scale some variables

irisWithNA$Sepal.Length <- scale(irisWithNA$Sepal.Length)

class(irisWithNA$Sepal.Length)

try(missRanger(irisWithNA, pmm.k = 3, num.trees = 100))

# convert back to vector

irisWithNA$Sepal.Length <- c(scale(irisWithNA$Sepal.Length))

missRanger(irisWithNA, pmm.k = 3, num.trees = 100)

It's not really a bug per se, just either some missing pre-processing or a need for an informative error message. I feel like it would be worthwhile to address given how common the scale function is in R.

@mayer79
Copy link
Owner

mayer79 commented Mar 23, 2021

Thanks a lot for reporting this one.

I don't think it is good practice to use a degenerate matrix instead of a vector. Still I will try to add a meaningful error message for such input.

@mayer79 mayer79 self-assigned this Mar 27, 2021
@mayer79 mayer79 closed this as completed Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants