Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 91bd4ee969
Fetching contributors…

Cannot retrieve contributors at this time

64 lines (58 sloc) 1.86 kb
\title{Change an object to an interval.}
as.interval(x, start)
\item{x}{a duration, difftime, period, or numeric object
that describes the length of the interval}
\item{start}{a POSIXt or Date object that describes when
the interval begins}
an interval object
as.interval changes difftime, Duration, Period and
numeric class objects to intervals that begin at the
specified date-time. Numeric objects are first coerced to
timespans equal to the numeric value in seconds.
as.interval can be used to create accurate
transformations between Period objects, which measure
time spans in variable length units, and Duration
objects, which measure timespans as an exact number of
seconds. A start date- time must be supplied to make the
conversion. Lubridate uses this start date to look up how
many seconds each variable length unit (e.g. month, year)
lasted for during the time span described. See
\code{\link{as.duration}}, \code{\link{as.period}}.
diff <- new_difftime(days = 31) #difftime
as.interval(diff, ymd("2009-01-01"))
# 2009-01-01 UTC--2009-02-01 UTC
as.interval(diff, ymd("2009-02-01"))
# 2009-02-01 UTC--2009-03-04 UTC
dur <- new_duration(days = 31) #duration
as.interval(dur, ymd("2009-01-01"))
# 2009-01-01 UTC--2009-02-01 UTC
as.interval(dur, ymd("2009-02-01"))
# 2009-02-01 UTC--2009-03-04 UTC
per <- new_period(months = 1) #period
as.interval(per, ymd("2009-01-01"))
# 2009-01-01 UTC--2009-02-01 UTC
as.interval(per, ymd("2009-02-01"))
# 2009-02-01 UTC--2009-03-01 UTC
as.interval(3600, ymd("2009-01-01")) #numeric
# 2009-01-01 UTC--2009-01-01 01:00:00 UTC
\code{\link{interval}}, \code{\link{new_interval}}
Jump to Line
Something went wrong with that request. Please try again.