Description Usage Arguments Details Value Output Format Author(s) Examples
nanoival is a time interval type (an S4 class) with
nanosecond functionality. One of its purposes is to allow quick
subsetting of a nanotime vector. nanoival is
composed of a nanotime pair which defines the start and end
of the time interval. Additionally, it has a pair of logical
values which determine if the start and end of the time interval
are open (true) or closed (false).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | nanoival(start, end, sopen = FALSE, eopen = TRUE)
## S4 method for signature 'nanoival'
start(x)
## S4 method for signature 'nanoival'
end(x)
## S4 method for signature 'nanoival'
sopen(x)
## S4 method for signature 'nanoival'
eopen(x)
## S4 method for signature 'nanoival'
print(x, ...)
## S4 method for signature 'nanoival'
show(object)
## S4 method for signature 'nanoival'
names(x)
## S4 replacement method for signature 'nanoival'
names(x) <- value
## S4 method for signature 'character'
as.nanoival(x, format = "", tz = "")
## S4 method for signature 'nanoival,nanoival'
e1 < e2
## S4 method for signature 'nanoival,nanoival'
e1 <= e2
## S4 method for signature 'nanoival,nanoival'
e1 > e2
## S4 method for signature 'nanoival,nanoival'
e1 >= e2
## S4 method for signature 'nanoival,nanoival'
e1 == e2
## S4 method for signature 'nanoival,nanoival'
e1 != e2
## S4 method for signature 'nanoival,ANY'
e1 - e2
## S4 method for signature 'nanoival,integer64'
e1 - e2
## S4 method for signature 'nanoival,numeric'
e1 - e2
## S4 method for signature 'ANY,nanoival'
e1 - e2
## S4 method for signature 'nanoival,ANY'
e1 + e2
## S4 method for signature 'nanoival,integer64'
e1 + e2
## S4 method for signature 'nanoival,numeric'
e1 + e2
## S4 method for signature 'ANY,nanoival'
e1 + e2
## S4 method for signature 'integer64,nanoival'
e1 + e2
## S4 method for signature 'numeric,nanoival'
e1 + e2
## S4 method for signature 'nanoival,nanoival'
e1 + e2
## S4 method for signature 'nanoival,ANY'
Arith(e1, e2)
## S4 method for signature 'nanoival,ANY'
Compare(e1, e2)
## S4 method for signature 'nanoival,ANY'
Logic(e1, e2)
## S4 method for signature 'ANY,nanoival'
Logic(e1, e2)
## S4 method for signature 'nanoival'
Math(x)
## S4 method for signature 'nanoival'
Math2(x, digits)
## S4 method for signature 'nanoival'
Summary(x, ..., na.rm = FALSE)
## S4 method for signature 'nanoival'
min(x, ..., na.rm = FALSE)
## S4 method for signature 'nanoival'
max(x, ..., na.rm = FALSE)
## S4 method for signature 'nanoival'
range(x, ..., na.rm = FALSE)
## S4 method for signature 'nanoival'
Complex(z)
## S4 method for signature 'nanoival,logical'
x[i, j, ..., drop = FALSE]
## S4 method for signature 'nanoival,numeric'
x[i, j, ..., drop = FALSE]
## S4 replacement method for signature 'nanoival,logical,ANY,nanoival'
x[i, j, ...] <- value
## S3 method for class 'nanoival'
c(...)
## S4 method for signature 'nanoival'
t(x)
## S4 method for signature 'nanoival,nanoival'
intersect(x, y)
## S4 method for signature 'nanoival,nanoival'
union(x, y)
## S4 method for signature 'nanoival,nanoival'
setdiff(x, y)
## S4 method for signature 'nanotime,nanoival'
x[i, j, ..., drop = TRUE]
## S4 method for signature 'nanotime,nanoival'
intersect(x, y)
## S4 method for signature 'nanotime,nanoival'
setdiff(x, y)
## S4 method for signature 'nanoival'
is.unsorted(x, na.rm = FALSE, strictly = FALSE)
## S4 method for signature 'nanoival'
sort(x, decreasing = FALSE, ...)
## S4 method for signature 'nanotime'
seq(from, to = NULL, by = NULL, length.out = NULL,
along.with = NULL, ...)
|
start |
|
end |
|
sopen |
logical indicating if the start of the interval is open |
eopen |
logical indicating if the end of the interval is open |
x |
a |
... |
further arguments passed to or from methods. |
object |
argument for method |
value |
argument for |
tz |
a timezone string |
e1 |
Operand of class |
e2 |
Operand of class |
digits |
Required for |
na.rm |
a logical indicating whether missing values should be removed. |
z |
Required for |
i |
index specifying elements to extract or replace. |
j |
Required for |
drop |
Required for |
recursive |
argument for method |
An interval object can be constructed with the constructor
nanoival which takes as arguments two nanotime
objects that define the start and the end of the interval,
together with two logical arguments that define if the
start and the end of the interval are open (true) or closed
(false) (note that these objects can all be vector, and therefore
the interval object is not necessarily scalar). Alternatively, an
interval can be constructed with a character: the format
follows that of nanotime; the start time is preceeded by
either - or + indicating if the interval start is
open (-) or closed (+); the start and end times are separated by
an arrow ->; the end is folloed by either - or
+ which have the same semantics as the start time.
The most important set of methods defined for interval are
set functions intersect, union and setdiff.
Additionally, interval allows the subsetting into a
nanotime vector. Note that subsetting is allowed only if
the nanotime vector is sorted.
Finally, accessors are provided to get the interval start
(start), the end (end), the open/close status of the
start (sopen) and the open/close status of the end
(eopen). The former return a nanotime while the
latter return a logical.
A nanoival object
Formatting and character conversion for nanoival objects is
identical to nanotime objects. The default format is
ISO3339 compliant: %Y-%m-%dT%H:%M:%E9S%Ez. It
specifies a standard ISO 8601 part for date and time — as well
as nine digits of precision for fractional seconds (down to
nanoseconds) and on offset (typically zero as we default to UTC).
It can be overriden by using options() with the key of
nanotimeFormat and a suitable value. Similarly,
nanotimeTz can be used to select a different timezone.
Leonardo Silvestri
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ## creating a \code{nanoival}, with the start time included ('+') and the end
## time excluded ('-')
as.nanoival("+2012-03-01T21:21:00.000000001+00:00->2015-01-01T21:22:00.000000999+04:00-")
## a \code{nanoival} can also be created with a pair of \code{nanotime} objects, a start
## and an end, and optionally two logicals determining if the interval start(end) are open
## or closed; by default the start is closed and end is open:
start <- nanotime("2012-03-01T21:21:00.000000001+00:00")
end <- nanotime("2013-03-01T21:21:00.000000001+00:00")
nanoival(start, end)
## a vector of \code{nanotime} can be subsetted by an interval:
fmt <- "%Y-%m-%d %H:%M:%S"
one_second <- 1e9
a <- seq(nanotime("2012-12-12 12:12:12", fmt), length.out=10, by=one_second)
idx <- c(as.nanoival("-2012-12-12 12:12:10 -> 2012-12-12 12:12:14-", fmt),
as.nanoival("+2012-12-12 12:12:18 -> 2012-12-12 12:12:20+", fmt))
a[idx]
## \code{nanoival} also has the set operations \code{union}, \code{intersect},
## \code{setdiff}
a <- seq(nanotime("2012-12-12 12:12:12", fmt), length.out=10, by=one_second)
i <- as.nanoival("-2012-12-12 12:12:14 -> 2012-12-12 12:12:18-", fmt)
setdiff(a, i)
i1 <- as.nanoival("+2012-12-12 12:12:14 -> 2012-12-12 12:12:17-", fmt)
i2 <- as.nanoival("+2012-12-12 12:12:16 -> 2012-12-12 12:12:18-", fmt)
union(i1, i2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.