knitr::opts_chunk$set(collapse = FALSE)
@export
tag but not @return
tag# Create fake package ---- pkg_path <- tempfile(pattern = "pkg.") dir.create(pkg_path) # Create fake package usethis::create_package(pkg_path, open = FALSE) # Create function no visible global variables and missing documented functions cat(" #' Function #' @importFrom dplyr filter #' @export my_fun <- function() { data %>% filter(col == 3) %>% mutate(new_col = 1) %>% ggplot() + aes(x, y, colour = new_col) + geom_point() } ", file = file.path(pkg_path, "R", "function.R")) attachment::att_amend_desc(path = pkg_path) # Files of the package fs::dir_tree(pkg_path, recurse = TRUE)
CRAN does not like when exported functions do not have returned value.
Using find_missing_tags()
, you can detect exported functions with missing or empty @return
tag
tags <- find_missing_tags(pkg_path) tags tags$functions
get_no_visible()
runs the checks and extract no visible global variables and missing documented functionsprint_globals()
proposes a template to add missing global variables in a globals.R
file.
Note that you can also transform all these variables with .data[[variable]]
# Get globals globals <- get_no_visible(pkg_path, quiet = TRUE) globals # Print globals to copy-paste print_globals(globals) # Store in package using usethis::use_r("globals")
# Run but keep eval=FALSE to avoid infinite loop # Execute in the console directly fusen::inflate(flat_file = "dev/flat_deal-with-check-outputs.Rmd", vignette_name = "Deal with check outputs", check = FALSE, document = TRUE, open_vignette = FALSE) # Pre-compilation of the vignette over itself to avoid too long calculation during checks knitr::knit( input = here::here("vignettes/deal-with-check-outputs.Rmd"), output = here::here("vignettes/deal-with-check-outputs.Rmd") ) rstudioapi::navigateToFile("dev/0-dev_history.Rmd", line = 96)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.