eco*_*013 5 r devtools s4 rstudio roxygen2
我正在使用 devtools 和 roxygen2 编写一个 R 包来做文档。该文档适用于除我的两个 R 文件之外的所有文件。对于这两个,第一个函数的文档文件 (.Rd) 是在没有 \title{} 行的情况下生成的。例如,这是我的普通 rd 文件顶部的样子:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/general.R
\name{rmsd}
\alias{rmsd}
\title{Calculates the Root Mean Squared Deviation/Error}
\usage{...`
Run Code Online (Sandbox Code Playgroud)
这是由代码块生成的:
#' Calculates the Root Mean Squared Deviation/Error
#'
#' This function calculates the root mean squared error/deviation (RMSD/E)
#' between two vectors of numbers.
#'
#' @param x numeric, the first vector
#' @param y numeric, the second vector
#' @param na.rm logical, should NAs be removed from the vectors?
#' @return This function returns the RMSD of the two vectors.
#' @examples
#' a <- rnorm(10)
#' b <- rnorm(10)
#' rmsd(a,b)
#' @export
rmsd <- function(...
Run Code Online (Sandbox Code Playgroud)
异常的看起来像这样:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/constructors.R
\name{parameterlist}
\alias{parameterlist}
\usage{...
Run Code Online (Sandbox Code Playgroud)
并由此代码块生成:
#' @include plantmethodsbasic.R thermal.R general.R
#This script has constructor functions for both ParameterList and Plant classes
#' Creates ParameterList object
#'
#' This function creates an object of the class ParameterList. Plant objects
#' require objects of the class ParameterList for their parameters slot.
#'
#' @param ct A list, data.frame, or matrix of cardinal temperatures. In the
#' case of a data.frame or matrix, each row should contain the cardinal
#' temperatures for a given stage of the model. If ct is a list, each
#' element of the list should be a vector of cardinal temperatures for a
#' given stage of the model.
#' @param length A vector of model lengths
#' @return An object of the class ParameterList.
#' @export
parameterlist <- function(...
Run Code Online (Sandbox Code Playgroud)
如果我在这些文件的顶部创建(并记录)一个虚拟函数并使用 devtools::document() 命令,该函数将成为没有标题的函数。如果我然后从文件中删除虚拟函数并重新记录包, \title{} 参数将从我的原始函数中删除。如果有人对正在发生的事情有任何想法,我将不胜感激。我可以自己编写其余的文档文件,但我不想这样做。
哦,如果重要的话,这是一个 S4 包。
谢谢!