-
-
Notifications
You must be signed in to change notification settings - Fork 996
Open
Description
This is something I noticed while looking at output on a blog post: https://tidyverse.org/blog/2025/11/two-new-tidymodels-packages/#important
Reproducible with
---
title: "testing"
output:
html_document:
keep_md: true
---
```{r}
library(tidymodels)
library(filtro)
set.seed(1)
yield_split <- initial_split(modeldata::chem_proc_yield)
yield_split
yield_train <- training(yield_split)
yield_test <- testing(yield_split)
```
```{r}
library(important)
library(desirability2)
goals <-
desirability(
maximize(cor_spearman, low = 0.25, high = 1),
maximize(imp_rf_oblique, scale = 2)
)
yield_rec <-
recipe(yield ~ ., data = yield_train) |>
step_impute_knn(all_predictors(), neighbors = 10) |>
step_predictor_desirability(
all_predictors(),
score = goals,
prop_terms = 1 / 10
)
yield_rec
```
Looking at recipes:::print.recipe(), it is using cli only
https://github.com/tidymodels/recipes/blob/810b5b55b912dcae8c57f6d0a8d4db75ca88f7cd/R/recipe.R#L875-L927
So we can reproduce using something like below
---
title: "testing"
output:
html_document:
keep_md: true
---
```{r}
print_cli <- function() {
cli::cli_div(theme = list(.pkg = list(`vec-trunc` = Inf,
`vec-last` = ", ")))
cli::cli_h1("Recipe")
cli::cli_h3("Inputs")
cli::cli_text("Number of variables by role")
tab <- c("X", "Y")
values <- 1:2
cli::cli_verbatim(glue::glue("{names(tab)}: {values}"))
cli::cli_end()
}
print_cli()
```
This is because we have this intermediate md
---
title: "testing"
output:
html_document:
keep_md: true
---
``` r
print_cli <- function() {
cli::cli_div(theme = list(.pkg = list(`vec-trunc` = Inf,
`vec-last` = ", ")))
cli::cli_h1("Recipe")
cli::cli_h3("Inputs")
cli::cli_text("Number of variables by role")
tab <- c("X", "Y")
values <- 1:2
cli::cli_verbatim(glue::glue("{names(tab)}: {values}"))
cli::cli_end()
}
print_cli()
```
```
##
```
```
## ── Recipe ──────────────────────────────────────────────────────────────────────
```
```
##
```
```
## ── Inputs
```
```
## Number of variables by role
```
```
##
```
Is this something we should try to improve in knitr or rmarkdown ? Or is this something related to cli usage ?
I'll look into cli logic to be sure, but maybe you gave ideas @yihui
Metadata
Metadata
Assignees
Labels
No labels