EVOLUTION-MANAGER
Edit File: packageDescription.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Package Description</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for packageDescription {utils}"><tr><td>packageDescription {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Package Description</h2> <h3>Description</h3> <p>Parses and returns the ‘<span class="file">DESCRIPTION</span>’ file of a package as a <code>"packageDescription"</code>. </p> <p>Utility functions return (transformed) parts of that. </p> <h3>Usage</h3> <pre> packageDescription(pkg, lib.loc = NULL, fields = NULL, drop = TRUE, encoding = "") packageVersion(pkg, lib.loc = NULL) packageDate(pkg, lib.loc = NULL, date.fields = c("Date", "Packaged", "Date/Publication", "Built"), tryFormats = c("%Y-%m-%d", "%Y/%m/%d", "%D", "%m/%d/%y"), desc = packageDescription(pkg, lib.loc=lib.loc, fields=date.fields)) asDateBuilt(built) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>pkg</code></td> <td> <p>a character string with the package name.</p> </td></tr> <tr valign="top"><td><code>lib.loc</code></td> <td> <p>a character vector of directory names of <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> libraries, or <code>NULL</code>. The default value of <code>NULL</code> corresponds to all libraries currently known. If the default is used, the loaded packages and namespaces are searched before the libraries.</p> </td></tr> <tr valign="top"><td><code>fields</code></td> <td> <p>a character vector giving the tags of fields to return (if other fields occur in the file they are ignored).</p> </td></tr> <tr valign="top"><td><code>drop</code></td> <td> <p>If <code>TRUE</code> and the length of <code>fields</code> is 1, then a single character string with the value of the respective field is returned instead of an object of class <code>"packageDescription"</code>.</p> </td></tr> <tr valign="top"><td><code>encoding</code></td> <td> <p>If there is an <code>Encoding</code> field, to what encoding should re-encoding be attempted? If <code>NA</code>, no re-encoding. The other values are as used by <code><a href="../../base/html/iconv.html">iconv</a></code>, so the default <code>""</code> indicates the encoding of the current locale.</p> </td></tr> <tr valign="top"><td><code>date.fields</code></td> <td> <p>character vector of field tags to be tried. The first for which <code><a href="../../base/html/as.Date.html">as.Date</a>(.)</code> is not <code><a href="../../base/html/NA.html">NA</a></code> will be returned. (Partly experimental, see <em>Note</em>.)</p> </td></tr> <tr valign="top"><td><code>tryFormats</code></td> <td> <p>date formats to try, see <code><a href="../../base/html/as.Date.html">as.Date.character</a>()</code>.</p> </td></tr> <tr valign="top"><td><code>desc</code></td> <td> <p>optionally, a named <code><a href="../../base/html/list.html">list</a></code> with components named from <code>date.fields</code>; where the default is fine, a complete <code>packageDescription()</code> maybe specified as well.</p> </td></tr> <tr valign="top"><td><code>built</code></td> <td> <p>for <code>asDateBuilt()</code>, a <code><a href="../../base/html/character.html">character</a></code> string as from <code>packageDescription(*, fields="Built")</code>.</p> </td></tr> </table> <h3>Details</h3> <p>A package will not be ‘found’ unless it has a ‘<span class="file">DESCRIPTION</span>’ file which contains a valid <code>Version</code> field. Different warnings are given when no package directory is found and when there is a suitable directory but no valid ‘<span class="file">DESCRIPTION</span>’ file. </p> <p>An <a href="../../base/html/attach.html">attach</a>ed environment named to look like a package (e.g., <code>package:utils2</code>) will be ignored. </p> <p><code>packageVersion()</code> is a convenience shortcut, allowing things like <code>if (packageVersion("MASS") < "7.3") { do.things } </code>. </p> <p>For <code>packageDate()</code>, if <code>desc</code> is valid, both <code>pkg</code> and <code>lib.loc</code> are not made use of. </p> <h3>Value</h3> <p>If a ‘<span class="file">DESCRIPTION</span>’ file for the given package is found and can successfully be read, <code>packageDescription</code> returns an object of class <code>"packageDescription"</code>, which is a named list with the values of the (given) fields as elements and the tags as names, unless <code>drop = TRUE</code>. </p> <p>If parsing the ‘<span class="file">DESCRIPTION</span>’ file was not successful, it returns a named list of <code>NA</code>s with the field tags as names if <code>fields</code> is not null, and <code>NA</code> otherwise. </p> <p><code>packageVersion()</code> returns a (length-one) object of class <code>"<a href="../../base/html/numeric_version.html">package_version</a>"</code>. </p> <p><code>packageDate()</code> will return a <code>"Date"</code> object from <code><a href="../../base/html/as.Date.html">as.Date</a>()</code> or <code>NA</code>. </p> <p><code>asDateBuilt(built)</code> returns a <code>"Date"</code> object or signals an error if <code>built</code> is invalid. </p> <h3>Note</h3> <p>The default behavior of <code>packageDate()</code>, notably for <code>date.fields</code>, is somewhat experimental and may change. Using <code>date.fields = <string></code> single </p> <h3>See Also</h3> <p><code><a href="../../base/html/dcf.html">read.dcf</a></code> </p> <h3>Examples</h3> <pre> packageDescription("stats") packageDescription("stats", fields = c("Package", "Version")) packageDescription("stats", fields = "Version") packageDescription("stats", fields = "Version", drop = FALSE) if(packageVersion("MASS") < "7.3.29") message("you need to update 'MASS'") pu <- packageDate("utils") str(pu) stopifnot(identical(pu, packageDate(desc = packageDescription("utils"))), identical(pu, packageDate("stats"))) # as "utils" and "stats" are # both 'base R' and "Built" at same time </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>