CRAN Task Views Documentation

Achim Zeileis

Overview

For more details on how to use task views and how to contribute to them, see the repository of the CRAN Task Views Initiative.

Format

The file format for CRAN task views leverages the R/Markdown format (see Xie, Allaire, Grolemund 2019) so that standard Markdown can be used for formatting and structuring the text and a handful of special R functions are provided to link to CRAN packages, other task views, GitHub projects, etc.

In ctv versions prior to 0.9-0 (released in December 2021), task views used an XML-based format (introduced in Zeileis 2005, R News, 5(1), 39-40 [PDF]). See below for converting task views from the old XML-based format to the new R/Markdown format.

The format is mostly self-explanatory and is illustrated below using an excerpt from the Econometrics task view which is hosted on CRAN at https://CRAN.R-project.org/view=Econometrics and maintained on GitHub at https://github.com/cran-task-views/Econometrics/.

---
name: Econometrics
topic: Econometrics
maintainer: Achim Zeileis, Grant McDermott, Kevin Tappe
email: Achim.Zeileis@R-project.org
version: 2022-09-13
source: https://github.com/cran-task-views/Econometrics/
---

Base R ships with a lot of functionality useful for (computational) econometrics,
in particular in the stats package. This functionality is complemented by many
packages on CRAN, a brief overview is given below. There is also a certain
overlap between the tools for econometrics in this view and those in the task
views on `r view("Finance")`, `r view("TimeSeries")`, and
`r view("CausalInference")`.

Further information can be formatted with standard Markdown syntax, e.g., for
_emphasizing text_ or showing something really important in **bold face**.
R/Markdown syntax with special functions can be used to link to a standard
package like `r pkg("mlogit")` or an important "core" package like
`r pkg("AER", priority = "core")`.

### Links
- Articles: [Special Volume on "Econometrics in R" in JSS (2008)](https://www.jstatsoft.org/v27/)
- [The Title of a Relevant Homepage](https://path/to/homepage/)

The document structure consists of three main blocks: (1) Some metainformation is given in the YAML header at the beginning (separated by lines with ---), followed by (2) the information in the main text, and (3) a concluding special section called ### Links.

Details

Metainformation

The metainformation needs to provide the following elements:

Main text

The information in the main text should be a short description of the packages, explaining which packages are useful for which tasks. Standard Markdown format can be used to structure the document with sections, itemized and enumerated lists, bold face, italics, etc.

Additionally, short R code chunks with special functions are used for linking to resources in the same repository: pkg() for regular packages, pkg(..., priority = "core") for important “core” packages, and view() for related task views. A convenience function doi() creates links for DOIs (digital object identifiers).

Moreover, code projects in other repositories can be linked by using the functions:

Note however that CRAN task views are intended mainly for packages on CRAN (as the name conveys). Thus, links to other repositories should be used for important packages/projects but not list all potentially relevant repositories. Also, it is not necessary to list the GitHub projects for all listed CRAN packages as these are typically provided on the package’s CRAN web page.

Working with task view files in R

To check whether a task view file has been formatted properly it can be read into R and printed. This should display the metainformation and the list of packages. Subsequently, it can be rendered to an HTML page and displayed in a browser for checking whether the information text is processed correctly. Finally, the function check_ctv_packages() can be used to check whether some of the listed packages are actually not available on CRAN or not currently maintained (archived).

For illustration, the code below employs the Econometrics.md file shipped within the ctv package. Instead a local MyTopic.md with resulting MyTopic.html could be used as well.

library("ctv")
file.copy(system.file("ctv", "Econometrics.md", package = "ctv"), "Econometrics.md")
ctv2html("Econometrics.md", cran = TRUE)
browseURL("Econometrics.html")
check_ctv_packages("Econometrics.md")

Note that the code above is intended for authors of CRAN task views. For end-users the functions ctv(), available.views(), install.views(), and update.views() are relevant. See https://github.com/cran-task-views/ctv/ for more details.

Dealing with archived packages

The CRAN packages listed in task views should ideally be maintained actively, so that improved versions are released by the corresponding maintainers in case the daily CRAN checks discover any issues.

However, it is not straightforward to test for active maintenance fully automatically and even actively maintained packages may be temporarily archived on CRAN. Hence, the following strategy is adopted:

Converting the legacy XML format to R/Markdown

The ctv package provides an (unexported) R function to facilitate the transition from the legacy XML format for the task view files to the new R/Markdown format described above. Simply using

ctv:::ctv_xml_to_rmd("MyTopic.ctv")

will create a MyTopic.md file from the .ctv file. This should do most necessary transformations automatically. However, it is recommended to thoroughly check the resulting file and improve it as appropriate. To check the resulting HTML output use

ctv2html("MyTopic.md")
browseURL("MyTopic.html")

Note that one important difference between the XML and R/Markdown format is that the “package list” does not need to be listed separately anymore, it is auto-generated from the “info” text. Similarly, the “links” just need to provide those links that are not auto-generated from the “info” text.