Skip to content

Commit

Permalink
Merge pull request #203 from tidymodels/strings_as_factors
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt authored Oct 13, 2023
2 parents cd8d730 + 079c887 commit e679e81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# embed (development version)

* `step_collapse_stringdist()` will now return predictors as factors.

# embed 1.1.2

## Improvements
Expand Down
4 changes: 3 additions & 1 deletion R/collapse_stringdist.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ bake.step_collapse_stringdist <- function(object, new_data, ...) {
collapse_apply <- function(x, dict) {
dict <- purrr::map_dfr(dict, ~ list(from = .x, to = .x[1]))

dict$to[match(x, dict$from)]
res <- dict$to[match(x, dict$from)]

factor(res, levels = unique(dict$to))
}

#' @export
Expand Down

0 comments on commit e679e81

Please sign in to comment.