next up previous contents index
Next: Documenting Data Sets Up: Build R Package Previous: Preparation   Contents   Index

Documenting R Functions

Suppose I have written a function as follows:
> my.layout <- function(m, n) {
+     par(mfrow = c(m, n))
+ }
And I want to write a Rd documentation for it. I can simply type:
> prompt(my.layout)
and R will output a template into the man folder, or whatever your current working directory happens to be. The resulting output, named my.layout.Rd has the content as follows:
\name{my.layout}
\alias{my.layout}
%- Also NEED an `\alias' for EACH other topic documented here.
\title{ ~~function to do ... ~~ }
\description{
  ~~ A concise (1-5 lines) description of what the function does. ~~
}
\usage{
my.layout(m, n)
}
%- maybe also `usage' for other objects documented here.
\arguments{
  \item{m}{ ~~Describe \code{m} here~~ }
  \item{n}{ ~~Describe \code{n} here~~ }
}
\details{
  ~~ If necessary, more details than the __description__  above ~~
}
\value{
  ~Describe the value returned
  If it is a LIST, use
  \item{comp1 }{Description of `comp1'}
  \item{comp2 }{Description of `comp2'}
  ...
}
\references{ ~put references to the literature/web site here ~ }
\author{ ~~who you are~~ }
\note{ ~~further notes~~ }

 ~Make other chapters like WARNING with \chapter{WARNING }{....} ~

\seealso{ ~~objects to SEE ALSO as \code{\link{~~fun~~}}, ~~~ }

\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--         or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(m, n) {
    par(mfrow = c(m, n))
  }
}
\keyword{ ~kwd1 }% at least one, from doc/KEYWORDS
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
You can then modify this file. Please refer to Writting R Extensions for more details on how to edit this file.

Ko-Kang Wang 2002-10-10