EVOLUTION-MANAGER
Edit File: time_length.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: Compute the exact length of a time span</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 time_length {lubridate}"><tr><td>time_length {lubridate}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Compute the exact length of a time span</h2> <h3>Description</h3> <p>Compute the exact length of a time span </p> <h3>Usage</h3> <pre> time_length(x, unit = "second") ## S4 method for signature 'Interval' time_length(x, unit = "second") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a duration, period, difftime or interval</p> </td></tr> <tr valign="top"><td><code>unit</code></td> <td> <p>a character string that specifies with time units to use</p> </td></tr> </table> <h3>Details</h3> <p>When <code>x</code> is an <a href="Interval-class.html">Interval</a> object and <code>unit</code> are years or months, <code>time_length()</code> takes into account the fact that all months and years don't have the same number of days. </p> <p>When <code>x</code> is a <a href="Duration-class.html">Duration</a>, <a href="Period-class.html">Period</a> or <code><a href="../../base/html/difftime.html">difftime()</a></code> object, length in months or years is based on their most common lengths in seconds (see <code><a href="timespan.html">timespan()</a></code>). </p> <h3>Value</h3> <p>the length of the interval in the specified unit. A negative number connotes a negative interval or duration </p> <h3>See Also</h3> <p><code><a href="timespan.html">timespan()</a></code> </p> <h3>Examples</h3> <pre> int <- interval(ymd("1980-01-01"), ymd("2014-09-18")) time_length(int, "week") # Exact age time_length(int, "year") # Age at last anniversary trunc(time_length(int, "year")) # Example of difference between intervals and durations int <- interval(ymd("1900-01-01"), ymd("1999-12-31")) time_length(int, "year") time_length(as.duration(int), "year") </pre> <hr /><div style="text-align: center;">[Package <em>lubridate</em> version 1.7.9 <a href="00Index.html">Index</a>]</div> </body></html>