我将 R 包从
.Rd
转换为 roxygen 文档,并且收到警告
从 R CMD 检查我无法理解和解决。
存在此问题的一个文件是ridge.R 由
.Rd
创建的 devtools::document()
文件是
ridge.Rd.
问题是我正在为
ridge
类定义多个 S3 方法,并且
这些在 \method{}{ridge}(arguments, ...)
下不会显示为 \usage{}
它为每个方法声明了 arguments
。因此,我收到的警告是:
Documented arguments not in \usage in documentation object 'ridge':
'X' 'formula' 'data' 'lambda' 'df' 'svd' 'x' 'object' 'digits'
Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.
我的[
ridge.R
(https://github.com/friend/genridge/blob/roxygenize/R/ridge.R)文件的一些相关部分:
#' Ridge Regression Estimates
#'
#' @name ridge
#' @aliases ridge ridge.default ridge.formula coef.ridge print.ridge vcov.ridge
#'
#' @description
#' The function \code{ridge} fits linear models by ridge regression, returning
#' an object of class \code{ridge} designed to be used with the plotting
#' methods in this package.
#'
#' @param y A numeric vector containing the response variable. NAs not allowed.
#' @param X A matrix of predictor variables. NA's not allowed. Should not
#' include a column of 1's for the intercept
#' @param formula For the \code{formula} method, a two-sided formula
#' @param data For the \code{formula} method, data frame within which to
#' evaluate the formula
#' @param lambda A scalar or vector of ridge constants. A value of 0
#' corresponds to ordinary least squares.
#' @param df A scalar or vector of effective degrees of freedom corresponding
#' to \code{lambda}
#' @param svd If \code{TRUE} the SVD of the centered and scaled \code{X} matrix
#' is returned in the \code{ridge} object.
#' @param x,object An object of class \code{ridge}
#' @param \dots Other arguments, passed down to methods
#' @param digits For the \code{print} method, the number of digits to print.
#'
#' @return A list with the following components:
...
#' @export
ridge <- function(y, ...) {
UseMethod("ridge")
}
#' @export
ridge.formula <-
function(formula, data, lambda=0, df, svd=TRUE, ...){
...
}
#' @export
ridge.default <-
function(y, X, lambda=0, df, svd=TRUE, ...){
...
}
...
在
.Rd
文件中,我得到:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ridge.R
\name{ridge}
\alias{ridge}
\alias{ridge.default}
\alias{ridge.formula}
\alias{coef.ridge}
\alias{print.ridge}
\alias{vcov.ridge}
\title{Ridge Regression Estimates}
\usage{
ridge(y, ...)
}
\arguments{
\item{y}{A numeric vector containing the response variable. NAs not allowed.}
\item{\dots}{Other arguments, passed down to methods}
\item{X}{A matrix of predictor variables. NA's not allowed. Should not
include a column of 1's for the intercept}
\item{formula}{For the \code{formula} method, a two-sided formula}
\item{data}{For the \code{formula} method, data frame within which to
evaluate the formula}
...
我预计
usage{}
部分包含 \method{}{}
调用:
\usage{
ridge(y, ...)
}
\method{ridge}{default}(y, X, data, lambda=0, df, svd=TRUE, ...)
\method{ridge}{formula}(formula, data, lambda=0, df, svd=TRUE, ...)
}
...