Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Using cli functions for logging to console splits output chunk #2606

Open
@cderv

Description

@cderv

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_splityield_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 atrecipes:::print.recipe(), it is usingcli 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()```
Image

This is because we have this intermediate md

---title:"testing"output:html_document:keep_md:true---```rprint_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:2cli::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 inknitr orrmarkdown ? Or is this something related tocli usage ?

I'll look intocli logic to be sure, but maybe you gave ideas@yihui

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp