Rev 52679 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{news}\alias{news}\title{Build and Query R or Package News Information}\description{Build and query the news for R or add-on packages.}\usage{news(query, package = "R", lib.loc = NULL, format = NULL,reader = NULL, db = NULL)}\arguments{\item{query}{an expression for selecting news entries}\item{package}{a character string giving the name of an installedadd-on package, or \code{"R"}.}\item{lib.loc}{a character vector of directory names of R libraries,or \code{NULL}. The default value of \code{NULL} corresponds to alllibraries currently known.}\item{format}{Not yet used.}\item{reader}{Not yet used.}\item{db}{a news db obtained from \code{news()}.}}\value{An data frame inheriting from class \code{"news_db"}.}\details{If \code{package} is \code{"R"} (default), a news db is built with thenews since the 2.10.0 release of R (corresponding to R's top-level\file{NEWS} file). Otherwise, if the given add-on package can befound in the given libraries, it is attempted to read its news instructured form from files \file{inst/NEWS.Rd}, \file{NEWS} or\file{inst/NEWS} (in that order).File \file{inst/NEWS.Rd} should be an Rd file given the entries as Rd\verb{\itemize} lists, grouped according to version using\verb{section} elements with names starting with a suitable prefix(e.g, \dQuote{Changes in version} followed by a space and the versionnumber, and optionally followed by a space and a parenthesized ISO8601 (\%Y-\%m-\%d, see \code{\link{strptime}}) format date, andpossibly further grouped according to categories using\verb{\subsection} elements named as the categories.The plain text \file{NEWS} files in add-on packages use a variety ofdifferent formats; the default news reader should be capable toextract individual news entries from a majority of packages from thestandard repositories, which use (slight variations of) the followingformat:\itemize{\item Entries are grouped according to version, with version header\dQuote{Changes in version} at the beginning of a line, followed bya version number, optionally followed by an ISO 8601 format date,possibly parenthesized.\item Entries may be grouped according to category, with a categoryheader (different from a version header) starting at the beginningof a line.\item Entries are written as itemize-type lists, using one of\samp{o}, \samp{*}, \samp{-} or \samp{+} as item tag. Entries mustbe indented, and ideally use a common indentation for the itemtexts.}Additional formats and readers may be supported in the future.Package \pkg{tools} provides an (internal) utility function\code{news2Rd} to convert plain text \file{NEWS} files to Rd. For\file{NEWS} files in a format which can successfully be handled by thedefault reader, package maintainers can use \code{tools:::news2Rd(dir,"NEWS.Rd")}, possibly with additional argument \code{codify = TRUE},with \code{dir} a character string specifying the path to a package'sroot directory. Upon success, the \file{NEWS.Rd} file can further beimproved and then be moved to the \file{inst} subdirectory of thepackage source directory.The news db built is a character data frame inheriting from\code{"news_db"} with variables \code{Version}, \code{Category},\code{Date} and \code{Text}, where the last contains the entry textsread, and the other variables may be \code{NA} if they were missing orcould not be determined.Using \code{query}, one can select news entries from the db. Ifmissing or \code{NULL}, the complete db is returned. Otherwise,\code{query} should be an expression involving (a subset of) thevariables \code{Version}, \code{Category}, \code{Date} and\code{Text}, and when evaluated within the db returning a logicalvector with length the number of entries in the db. The entries forwhich evaluation gave \code{TRUE} are selected. When evaluating,\code{Version} and \code{Date} are coerced to\code{\link{numeric_version}} and \code{\link{Date}} objects,respectively, so that the comparison operators for these classes canbe employed.}\examples{## Build a db of all R news entries.db <- news()## Bug fixes with PR number in 2.11.0.news(Version == "2.11.0" & grepl("^BUG", Category) & grepl("PR#", Text),db = db)## Entries with version >= 2.10.1 (including "2.10.1 patched"):table(news(Version >= "2.10.1", db = db)$Version)}