EVOLUTION-MANAGER
Edit File: cut.POSIXt.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: Convert a Date or Date-Time Object to a Factor</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 cut.POSIXt {base}"><tr><td>cut.POSIXt {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Convert a Date or Date-Time Object to a Factor</h2> <h3>Description</h3> <p>Method for <code><a href="cut.html">cut</a></code> applied to date-time objects. </p> <h3>Usage</h3> <pre> ## S3 method for class 'POSIXt' cut(x, breaks, labels = NULL, start.on.monday = TRUE, right = FALSE, ...) ## S3 method for class 'Date' cut(x, breaks, labels = NULL, start.on.monday = TRUE, right = FALSE, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>an object inheriting from class <code>"POSIXt"</code> or <code>"Date"</code>.</p> </td></tr> <tr valign="top"><td><code>breaks</code></td> <td> <p>a vector of cut points <em>or</em> number giving the number of intervals which <code>x</code> is to be cut into <em>or</em> an interval specification, one of <code>"sec"</code>, <code>"min"</code>, <code>"hour"</code>, <code>"day"</code>, <code>"DSTday"</code>, <code>"week"</code>, <code>"month"</code>, <code>"quarter"</code> or <code>"year"</code>, optionally preceded by an integer and a space, or followed by <code>"s"</code>. (For <code>"Date"</code> objects only interval specifications using <code>"day"</code>, <code>"week"</code>, <code>"month"</code>, <code>"quarter"</code> and <code>"year"</code> are allowed.) </p> </td></tr> <tr valign="top"><td><code>labels</code></td> <td> <p>labels for the levels of the resulting category. By default, labels are constructed from the left-hand end of the intervals (which are included for the default value of <code>right</code>). If <code>labels = FALSE</code>, simple integer codes are returned instead of a factor. </p> </td></tr> <tr valign="top"><td><code>start.on.monday</code></td> <td> <p>logical. If <code>breaks = "weeks"</code>, should the week start on Mondays or Sundays?</p> </td></tr> <tr valign="top"><td><code>right, ...</code></td> <td> <p>arguments to be passed to or from other methods.</p> </td></tr> </table> <h3>Details</h3> <p>Note that the default for <code>right</code> differs from the <a href="cut.html">default method</a>. Using <code>include.lowest = TRUE</code> will include both ends of the range of dates. </p> <p>Using <code>breaks = "quarter"</code> will create intervals of 3 calendar months, with the intervals beginning on January 1, April 1, July 1 or October 1 (based upon <code>min(x)</code>) as appropriate. </p> <p>A vector of <code>breaks</code> will be sorted before use: <code>labels</code> should correspond to the sorted vector. </p> <h3>Value</h3> <p>A factor is returned, unless <code>labels = FALSE</code> which returns the integer level codes. </p> <p>Values which fall outside the range of <code>breaks</code> are coded as <code>NA</code>, as are and <code>NA</code> values. </p> <h3>See Also</h3> <p><code><a href="seq.POSIXt.html">seq.POSIXt</a></code>, <code><a href="seq.Date.html">seq.Date</a></code>, <code><a href="cut.html">cut</a></code> </p> <h3>Examples</h3> <pre> ## random dates in a 10-week period cut(ISOdate(2001, 1, 1) + 70*86400*stats::runif(100), "weeks") cut(as.Date("2001/1/1") + 70*stats::runif(100), "weeks") # The standards all have midnight as the start of the day, but some # people incorrectly interpret it at the end of the previous day ... tm <- seq(as.POSIXct("2012-06-01 06:00"), by = "6 hours", length.out = 24) aggregate(1:24, list(day = cut(tm, "days")), mean) # and a version with midnight included in the previous day: aggregate(1:24, list(day = cut(tm, "days", right = TRUE)), mean) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>