Search code examples
rdevtoolsroxygen2

Why does devtools give me a warning that @slot requires name and description


I have setup the following class in my customised R package:

#' A stock.returns class is an xts of stock(s) returns, a timeframe and the currency used.
#'
#' @slot xts_returns An xts of stock returns (potentially multiple stocks)
#' @slot timeframe
#' @slot currency Any three letter currency, or "Local"
#' @include timeframe.R
#' @export
stock.returns <- setClass(
    Class = "stock.returns",
    slots = c(xts_returns = "xts", timeframe = "timeframe", currency = "character"),
    prototype = prototype(xts_returns = xts::xts(, order.by = c(lubridate::today())), timeframe = timeframe(), currency = "Local")
)

#' A stock.returns class is an xts of stock(s) returns, a timeframe and the currency used.
#'
#' @param timeframe
#' @param benchmark_code The code for the index of stocks you want the returns for.
#' @param portfolio_code The code for the portfolio of stocks you want the returns for.
#' @param sec_id_list An explicit list of sec_id's you want the returns for.
#' @param currency Any three letter currency, or "Local".  The default is "AUD".
#' @export
stock.returns <- function(
    timeframe, benchmark_code, portfolio_code, sec_id_list, currency = "AUD") { 
        # ... code goes here ...
}

When I run devtools::document to auto-generate my .Rd files, why do I get the following warnings?

Warning:
 @slot [stock.returns.R#16]: requires name and description
Warning:
 @param [stock.returns.R#28]: requires name and description

Solution

  • Documented function parameters require both a name AND a description.

    In your code, the @slot timeframe and @param timeframe only have the name component, they need a description too (just like all your other parameters)

    This wont affect/stop a package from building or installing, but to get a package on CRAN you need to complete all the required parameters and descriptions.