You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The output shows diet as a factor, which suggests to me that the step_factor2string was ignored. Above it is mentioned "that prep() defaults with strings_as_factor = TRUE. So its converting Species to a factor before running any steps" so I understand in my test case:
Prep should ensure strings as factors
step_factor2string(diet) should be setting diet to a string
Apologies if I am doing something wrong, or if not, whether this should be listed as a new issue - it seemed related to this one...
suppressPackageStartupMessages(library(recipes))
data(okc)
string_test<- recipe(~diet+location, data=okc) %>%
step_factor2string(diet)
p_rec<- prep(string_test, okc, strings_as_factors=TRUE, retain=TRUE)
# diet is characterp_rec$template#> # A tibble: 59,855 x 2#> diet location #> <chr> <fct> #> 1 strictly anything south san francisco#> 2 mostly other oakland #> 3 anything san francisco #> 4 vegetarian berkeley #> 5 <NA> san francisco #> 6 mostly anything san francisco #> 7 strictly anything san francisco #> 8 mostly anything san francisco #> 9 strictly anything belvedere tiburon #> 10 mostly anything san mateo #> # … with 59,845 more rows# but there are levels stored for `diet`
names(p_rec$levels)
#> [1] "diet" "location"# so juice() converts them to factors# is this expected? I wouldn't think# juice() would do anything like this
juice(p_rec)
#> # A tibble: 59,855 x 2#> diet location #> <fct> <fct> #> 1 strictly anything south san francisco#> 2 mostly other oakland #> 3 anything san francisco #> 4 vegetarian berkeley #> 5 <NA> san francisco #> 6 mostly anything san francisco #> 7 strictly anything san francisco #> 8 mostly anything san francisco #> 9 strictly anything belvedere tiburon #> 10 mostly anything san mateo #> # … with 59,845 more rows
Created on 2019-04-04 by the reprex package (v0.2.1.9000)
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.
Activity
DavisVaughan commentedon Apr 4, 2019
reprex
Created on 2019-04-04 by the reprex package (v0.2.1.9000)
EmilHvitfeldt commentedon Sep 18, 2023
updated reprex:
Created on 2023-09-18 with reprex v2.0.2
github-actions commentedon Nov 17, 2023
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.