recipes icon indicating copy to clipboard operation
recipes copied to clipboard

audit use of ... in package

Open EmilHvitfeldt opened this issue 1 year ago • 1 comments
trafficstars

The ... are used throughout the package for different things.

Many of the steps define them themselves where it would probably be better if they were to be inherited.

Other functions such as prep() says ... aren't used, and should probably be checked as I suspect that some people are using prep(data = ddd) instead of prep(training = ddd)

EmilHvitfeldt avatar Nov 30 '23 21:11 EmilHvitfeldt

library(tidyverse)
library(recipes)

steps <- ls(getNamespace("recipes")) |>
  stringr::str_subset("^step_") |>
  stringr::str_subset("_new$", negate = TRUE) |>
  setdiff("step_testthat_helper")


get_arg <- function(x) {
  res <- getFromNamespace(x, getNamespace("recipes"))
  res <- formals(res)
  res$keep_original_cols
}

get_doc <- function(x) {
  readLines(paste0("man/", x, ".Rd")) |>
    paste(collapse = " ") |>
    str_extract("\\item\\{\\.\\.\\.\\}\\{.*?\\item") |>
    str_remove("\\item\\{\\.\\.\\.\\}\\{") |>
    str_remove("\\} *\\\\item")
}

dots <- tibble(
  name = steps
) |>
  mutate(doc = map_chr(name, get_doc)) |>
  filter(str_detect(name, "impute$", negate = TRUE)) 

dots |>
  count(doc) |>
  pull(doc)

dots |>
  filter(is.na(doc))

EmilHvitfeldt avatar May 24 '24 20:05 EmilHvitfeldt