Add @usage data('diamonds') to vignettes/rd-other.Rmd
Dear developers, thank you for your great work!
When documenting a dataset, I followed the template you provide in vignettes/rd-other.Rmd.
This structure caused a warning in R CMD check --as-cran:
- checking for code/documentation mismatches ... WARNING Variables with usage in Rd file 'datadoc.Rd' but not in code: ‘docdata’
After a bit of trial and error, this warning could be removed by adding a usage section to the documentation block: #' @usage data('docdata')
I'm convinced that if you were to add a simple @usage data('diamonds') to your example on data documentation, you could help many future users avoid unnecessary CRAN check warnings.
Best, Lena
(Not a dev here.) I think this is the start of some great improvements against issues I've been finding.
For instance, if I have the following in ./R/mydata.R:
#' Some Data.
#'
#' Something goes here.
#'
#' @format data.frame
#'
#' @usage data("somedata")
"somedata"
(The @usage is a recent add due to your comment above.) I have ./data/somedata.rda. In a package function, I use somedata[, .(...)] (it's really a data.table, but that's not important here). devtools::check(..) complains:
my_func: no visible binding for global variable 'somedata'
It is not exported. There is nothing fancy about it. But having done everything (afaict) that the roxygen2 docs say to do for data, I still get warnings about it. The only remedy I've found is rather nuclear, including this in one or more of my .R files (outside of a function definition):
utils::globalVariables("somedata")
I write this here as a comment and not as a new issue since I think it's all related. If y'all (OP and/or devs) think this is best as a new issue, I'll happily open one there too. Thanks!
Possibly related to {codetools} bug:
https://gitlab.com/luke-tierney/codetools/-/issues/8