Reputation: 1915
I have written an R package for integrating with electronic medical records. I think I have correctly added the imports and dependencies in the DESCRIPTION file and documented everything via roxygen2, but on three of my functions (which are all in the same file) I get this warning when I run devtools::check("."):
* checking for missing documentation entries ... WARNING
Undocumented code objects:
'add_to_database' 'database' 'import_CPRD_data'
All user-level objects in a package should have documentation entries.
I think I have documented these in the same way as all of my other functions which are fine. Here is one of the offending functions with the roxygen2 documentation:
#' Wrapper for dbconnect
#'
#' Connects to a SQLite database or creates one if it does not already exist
#'
#' If the '.sqlite' file extension is ommited from the dbname argument it is automatically added.
#'
#' @export
#'
#' @param dbname character name path to database file
#' @return SQLiteConnection object
#' @examples \dontrun{
#' db <- database("mydb")
#' }
database <- function(dbname){
if(!str_detect(dbname, "\\.sqlite$")) {
dbname <- paste(dbname, "sqlite", sep = ".")
}
dbConnect(SQLite(), dbname)
}
How can I get rid of this error? I have added stringr and RSQLite to the depends section of the DESCRIPTION file and they show up in NAMESPACE, so I don't think this is an import problem - but then what am I failing to document? The full package is here and the file with the file with the offending functions is here. I have looked in the writing R extensions manual and can't find the problem - don't know if I am just going blind from looking - but I can't see what I am doing differently in these functions from the others I have written!
Upvotes: 25
Views: 9497
Reputation: 12142
After several frustrating hours, I found that I had man/ in my .Rbuildignore file. 🤦
Upvotes: 0
Reputation: 6130
I was experimenting with the toy foofactors
package in Hadley Wickam's book. My data.R
file included:
#' A character string
#'
"MyString"
and fbind.R
had:
#' Print a string
#'
#' Returns the string MyString
#'
#' @export
#'
myString <- function() {
print(foofactors::MyString)
}
check
complained that there was undocumented code and data. I fixed this by chnaging the function name to theString
. So it appears that the names are not case sensitive which is odd.
Upvotes: 0
Reputation: 19
I ran across the undocumented code error when I had multiple functions to export. I think you need to add #' @describeIn. Here's my example.
#' @title Colors Definition
#'
#' @description Define colors with transparency value.
#'
#' @param alpha Transparency value (0-1), default 1.
#'
#' @return hex value of the color
#'
#' @examples
#' Get_Red(0.5)
#' Get_Red()
#'
#' @export Get_Red
#' @export Get_Blue
#'
Get_Red <- function(alpha = 1) {
rgb(228 / 255, 26 / 255, 28 / 255, alpha)
}
#' @describeIn Get_Red Blue color function with transparency value.
Get_Blue <- function(alpha = 1) {
rgb(55 / 255, 126 / 255, 184 / 255, alpha)
}
Upvotes: 1
Reputation: 1479
I fixed this same error message by installing the devtools
package.
In my case, I had created a new package on a new laptop and installed all the usual R
packages and accessories: installr, testthat, roxygen2
and also the accessory tools like rtools
and MiKteX
. When building the package I got the same error message "checking for missing documentation entries ... WARNING: Undocumented code objects". But I fully resolved the problem by also installing the devtools
package.
Upvotes: -1
Reputation: 3504
EDIT:
@R Yoda solved the problem stated in my "answer": It was related to a conflict between .Rbuildignore
and the function name (more precisley, the file name of the function's documentation).
Same problem here. And for me, it was related to the name of the function. When the name of the function below is load_rdata
(or loadrdata
), I receive the warning Undocumented code objects: 'load_rdata'
. When I rename the function to load_rda
, everything is fine.
I know this is half a question (why is this happening), half an answer (maybe because of the function names), but I thought it might help somebody coming across this question.
#' Load RData file.
#'
#' @param file An RData file saved via \code{\link[base]{save}}.
#' @return The object save in \code{file}.
#' @references \url{http://stackoverflow.com/a/5577647}
#' @export
load_rdata <- function(file = NULL) {
env <- new.env()
nm <- load(file, env)[1]
env[[nm]]
}
This is the output from sesssionInfo()
and was reproducible when using devtools 1.12.0 and roxygen2 6.0.0 instead.
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_1.12.0.9000 roxygen2_6.0.0.9000
loaded via a namespace (and not attached):
[1] R6_2.2.0 magrittr_1.5 tools_3.3.2 withr_1.0.2 memoise_1.0.0
[6] Rcpp_0.12.9 xml2_1.1.1 stringi_1.1.2 pkgload_0.0.0.9000 digest_0.6.12
[11] stringr_1.1.0 pkgbuild_0.0.0.9000 commonmark_1.1
Upvotes: 7
Reputation: 8770
I have had a similar problem when doing an R CMD check
:
Status: 1 WARNING
checking for missing documentation entries ... WARNING
Undocumented code objects:
‘build.log.output’
After removing all files step-by-step I have found the reason: The .Rbuildignore
file! It contained (besides other lines) one line with
^.*\.log
The last line makes R ignoring all files containing a ".log" in its name and my function was named "build.log.output" which caused R to ignore the documentation file "build.log.output.Rd" generated by Roxygen2 when creating the package file.
Therefore R CMD check
could not find the documentation in the package file!
Solution:
Improve the regular expression to ignore only real log files:
^.*\.log$
("$" means matching the end of line).
Voila :-)
Upvotes: 13
Reputation: 13076
You use roxygen, but most likely you don't roxygenize your package on build.
Either call:
roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))
or, if you use RStudio, edit Project Options (Tools menu) and in the Build Tools tab check Generate documentation with Roxygen.
Upvotes: 11