Back

pkgdown integration

Integrating pkgdown’s documentation into the website

R was introduced more than 20 years ago and contains nearly 800 000 lines of code (most of which are written in C) and is maintained by the R Code Team, a group of 20 statisticians focusing on making R a stable platform for data analysis and therefore being very conservative not to break existing code. However, R provides natively a powerful add-on system to extend the language.

R Packages #

R extensions aka packages provide a mechanism for loading optional code, data and documentation into R. They are the fundamental unit of shareable code. For an introduction, you can refer to R Packages.

/

  • R* <= Code
  • DESCRIPTION* <= Metadata
  • NAMESPACE** <= for CRAN
  • data <= Binary Datasets (.Rda)
  • data-raw <= Forge of reproductible datasets
  • man <= Documentation Files (.Rd)
  • tests <= Unit tests
  • vignettes <= Articles / Long-form documentation
  • inst
    • extdata <= Other Datasets

The structure of an R package is documentated

R Package Documentation #

R objects (functions but also datasets) are documented in files written in “R documentation” (.Rd) format, a markup language much of which closely resembles (La)TeX, which can be processed into a variety of formats, including LaTeX, HTML and plain text.

Here’s a sample .Rd file for the load base R function:

 1% File src/library/base/man/load.Rd
 2\name{load}
 3\alias{load}
 4\title{Reload Saved Datasets}
 5\description{
 6  Reload the datasets written to a file with the function
 7  \code{save}.
 8}
 9\usage{
10load(file, envir = parent.frame())
11}
12\arguments{
13  \item{file}{a connection or a character string giving the
14    name of the file to load.}
15  \item{envir}{the environment where the data should be
16    loaded.}
17}
18\seealso{
19  \code{\link{save}}.
20}
21\examples{
22## save all data
23save(list = ls(), file= "all.RData")
24
25## restore the saved values to the current environment
26load("all.RData")
27
28## restore the saved values to the workspace
29load("all.RData", .GlobalEnv)
30}
31\keyword{file}

.Rd files are stored in the man (manual) directory

Rd files based on LaTeX

rxoygen2 for literate programing (like java doc or python X)

with markdown support

pkgdown #

pkgdown makes it easy to build a website for an R package.

Pros:

Cons:

Metadata
PublicationMay 28, 2022
Last editMay 31, 2022
SourcesView source
LicenseCreative CommonsAttribution - Some rights reserved
ContributeSuggest change
Comments