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

Problem with geometry variables in Step_impute #1402

Open
nhward opened this issue Nov 28, 2024 · 0 comments
Open

Problem with geometry variables in Step_impute #1402

nhward opened this issue Nov 28, 2024 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@nhward
Copy link

nhward commented Nov 28, 2024

This bug is related to #1394 in that it involves spatial data frames. The complete.cases() line in step_impute_* does not work with geometry (i.e. 'sfc' classed) variables. I am not sure why the variable is even looked at as it should play no part in the imputation due to the role I have given it.

This may be related to #1374

Reproducible example:

library(recipes)
library(sf)
data <- sf::st_read(system.file("shape/nc.shp", package="sf"))

class(data) <- setdiff(class(data), "sf")
class(data$geometry)

recipes::recipe(formula = ~ ., data = data) |>
  recipes::update_role(geometry, new_role = "geometry") |>
  recipes::step_impute_knn(all_predictors()) |>
  recipes::prep(strings_to_factors = FALSE)

#> Error in `step_impute_knn()`:
#> Caused by error in `complete.cases()`:
#> ! invalid 'type' (list) of argument

Don't be confused by the column called "geometry" and the role called "geometry".

@EmilHvitfeldt EmilHvitfeldt added the bug an unexpected problem or unintended behavior label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants