Skip to content

Error: Subscript ina is a matrix #32

@mbac

Description

@mbac

Hi,

I’m getting the following error, and I wonder if you could help me understand its cause:

library(dplyr)
library(simputation)

kdata <- tribble(
    ~age, ~ct, ~pfratio, ~bmi,
    56,   86,   130,   30,
    58,   NA,   110,   NA,
    78,   NA,   NA,    28,
    54,   NA,   NA,    NA,
    45,   45,   230,   28,
    54,   45,   NA,    29
)

impute_knn(
    kdata,
        bmi ~ .,
        pool = "univariate"
    )
#> Warning: Requested k = 5 while 4 donors present. Using k = 4.
#> Error: Subscript `ina` is a matrix, the data `donors[ina]` must have size 1.

Created on 2021-05-30 by the reprex package (v2.0.0)

The same happens if I had more variables to the formula’s left-hand side (e.g., bmi + ct + pfratio ~ .).

I understand the warning that appears in this reprex. However, my actual data is in the hundreds of observations, yet it does have its fair share of NAs, and occasionally there can be up to 3 NAs per row. Is the error related to NAs in predictor variables?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions