View source: R/check_unused_objects.R
| check_unused_objects | R Documentation |
Recursively searches for R/Quarto files and applies
check_unused_objects_single_file() to each, collating results.
check_unused_objects(
root = ".",
patterns = c("\\.R$", "\\.r$", "\\.Rmd$", "\\.rmd$", "\\.qmd$", "\\.Qmd$"),
exclude_dirs = c(".git", "renv", "_site", "_freeze", ".quarto", "_book", "tools"),
verbose = FALSE
)
root |
Character scalar. Directory to search from (default |
patterns |
Character vector of regexes for file extensions to include. Defaults to common R and Quarto suffixes. |
exclude_dirs |
Character vector of directory names to skip anywhere in
the path (default: |
verbose |
Logical; if |
Supported extensions: .R, .r, .Rmd, .rmd, .qmd, .Qmd.
A data frame with columns:
File path (character).
Name of an object that is created but never used (character).
One row per unused object. If none are found, returns an empty data frame with the two columns.
project <- file.path(tempdir(), "unused_objects_demo")
dir.create(project)
writeLines(
c(
"df1 <- data.frame(x = 1:3)",
"df2 <- transform(df1, y = x * 2) # never used",
"print(df1)"
),
file.path(project, "analysis.R")
)
check_unused_objects(project)
unlink(project, recursive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.