Skip to content

[idea] return a list + print method #3

Open
@Athospd

Description

@Athospd

Hello @topepo

Imagine if foo <- usemodels::use_xgboost(mpg~., mtcars) would return a list of code chunks, like

foo <- list();
foo$recipe <- "xgb_recipe <- 
  recipe(formula = mpg ~ ., data = mtcars) %>% 
  step_zv(all_predictors()) "
foo$recipe
#> [1] "xgb_recipe <- \n  recipe(formula = mpg ~ ., data = mtcars) %>% \n  step_zv(all_predictors()) "
cat(foo$recipe)
#> xgb_recipe <- 
#>   recipe(formula = mpg ~ ., data = mtcars) %>% 
#>   step_zv(all_predictors())

Created on 2020-06-18 by the reprex package (v0.3.0)

It would suit perfectly for build custom rstudio snippets programatically, like this one by @RobertMyles https://www.robertmylesmcdonnell.com/content/posts/modelscript/

The cat()'s could live inside a print() S3 method...

I would love to contribute with this if it sounds like a good idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions