I receive the following note when trying to check my package: Found the following apparent S3 methods exported but not registered: is.nan.data.frame.
Here is my document that I use with roxygen2 to create the package documentation:
#' @title
#' NaN (Not a Number).
#'
#' @description
#' Check whether a value is "Not A Number" (\code{NaN}) in a dataframe.
#'
#' @details
#' [INSERT].
#'
#' @param x Dataframe.
#'
#' @return \code{TRUE} or \code{FALSE}, indicating whether values in a dataframe
#' are Not a Number (\code{NA}).
#'
#' @family dataEvaluations
#'
#' @usage is.nan.data.frame(x)
#'
#' @examples
#' # Prepare Data
#' df <- data.frame(item1 = rnorm(1000), item2 = rnorm(1000), item3 = rnorm(1000))
#' df[sample(1:nrow(df), size = 100), c("item1","item2","item3")] <- NaN
#'
#' # Calculate Missingness-Adjusted Row Sum
#' is.nan.data.frame(df)
#'
#' @seealso
#' \url{https://stackoverflow.com/questions/18142117/how-to-replace-nan-value-with-zero-in-a-huge-data-frame/18143097#18143097}
#'
#' @method is.nan data.frame
#'
#' @export is.nan.data.frame
is.nan.data.frame <- function(x) do.call(cbind, lapply(x, is.nan))
Here is the relevant line from my NAMESPACE file:
export(is.nan.data.frame)
Note that I receive the following warning when running roxygen2:
> library("roxygen2")
> roxygenise()
i Loading petersenlab
Writing NAMESPACE
Writing NAMESPACE
Warning message:
In setup_ns_exports(path, export_all, export_imports) :
Objects listed as exports, but not present in namespace: data.frame, is.nan
Here is the relevant output when I run the package check:
N checking S3 generic/method consistency (3.3s)
Found the following apparent S3 methods exported but not registered:
is.nan.data.frame
See section 'Registering S3 methods' in the 'Writing R Extensions'
manual.
...
S3 methods shown with full name in documentation object 'is.nan.data.frame':
'is.nan.data.frame'
The \usage entries for S3 methods should use the \method markup and not
their full name.
It seems one solution to this is to rename the function to use underscore separators (_) rather than dot separators (.) (How to register methods without referring to the S3 ones). However, I'd like to keep the dot separators (.) if possible so that I can use the is.nan() function with vectors and dataframes (via method dispatch). How can I export this function and get rid of the note?
FYI here is the fixed documentation after resolving the issues (based on the helpful answer and comments)--this no longer throws a note or warning:
#' @title
#' NaN (Not a Number).
#'
#' @description
#' Check whether a value is "Not A Number" (\code{NaN}) in a dataframe.
#'
#' @details
#' [INSERT].
#'
#' @param x Dataframe.
#'
#' @return \code{TRUE} or \code{FALSE}, indicating whether values in a dataframe
#' are Not a Number (\code{NA}).
#'
#' @family dataEvaluations
#'
#' @examples
#' # Prepare Data
#' df <- data.frame(item1 = rnorm(1000), item2 = rnorm(1000), item3 = rnorm(1000))
#' df[sample(1:nrow(df), size = 100), c("item1","item2","item3")] <- NaN
#'
#' # Calculate Missingness-Adjusted Row Sum
#' is.nan(df)
#'
#' @seealso
#' \url{https://stackoverflow.com/questions/18142117/how-to-replace-nan-value-with-zero-in-a-huge-data-frame/18143097#18143097}
#'
#' @method is.nan data.frame
#'
#' @export
is.nan.data.frame <- function(x) do.call(cbind, lapply(x, is.nan))