bdTimeSeries
, signal, or
bdSignalSeries
to new positions.
align(x, pos, how="NA", error.how="NA", localzone=F, matchtol=0, by, k.by=1, week.align=NULL, holidays=timeDate())
pos
or
by
is required).
"NA"
- insert a row of
NA
;
"drop"
- drop that position entirely;
"nearest"
- use the row with
the nearest position;
"before"
- use the data from the row whose position
is just before the unmatched position;
"after"
- use the data from
the row whose position is
just after the unmatched position;
"interp"
- interpolate linearly
between
"before"
and
"after"
.
"before"
,
"after"
, or
"interp"
), one of:
"NA"
- insert a row of
NA
;
"drop"
- drop that position
entirely;
"nearest"
- use the row with the nearest position.
x
must be a calendar-based time series or
bdTimeSeries
),
align by matching/interpolating with
both
x
and
pos
in their local time zones, instead of with
the absolute GMT times.
matchtol
will
not invoke any of the
how
argument methods.
pos
is missing and
by
is supplied for aligning a
calendar-based time series or
bdTimeSeries
, new positions are generated as a regular
time/date sequence using
by
,
k.by
,
week.align
,
and
holidays
.
by
gives the spacing between successive values in the sequence.
This can be a
timeSpan
,
bdTimeSpan
,
timeRelative
, or
numeric
value,
in which case
k.by
is ignored.
Alternatively, it can be one
of the following character strings:
"milliseconds"
,
"seconds"
,
"minutes"
,
"hours"
,
"days"
,
"weekdays"
,
"bizdays"
,
"weeks"
,
"months"
,
"quarters"
,
or
"years"
, giving the time units of intervals between values in
the sequence.
by
. Ignored if
by
is not a character string or if
pos
is given.
NULL
and
by
is
"weeks"
,
you can supply a character
string (or a number, 0 to 6 with 0 being Sunday)
to specify a weekday to align to. The character string must
be sufficient to make a unique case-insensitive match to the strings
in
options("time.day.name")
. Ignored if
by
is not a character string or
pos
is given.
by
is not
a character string or
pos
is given).
bdTimeSeries
, signal, or
bdSignalSeries
whose positions are the passed-in positions or
positions generated from
by
,
k.by
etc.
(or possibly a subset if
how
or
error.how
is
"drop"
) and whose
rows are derived from
x
as specified in the arguments.
If either
x
or
pos
(or the generated sequence) has zero length,
a zero-length series will be
returned.
a <- signalSeries(pos=1:10, data=data.frame(a = 11:20, b = 5 * (1:10))) align(a, c(.2, 3, 7.8, 12), how = "interp", error.how = "nearest") a <- timeSeries(pos=as(1:10, "timeDate"), data=data.frame(a = 11:20, b = 5 * (1:10))) alpos <- as(c(.2, 3, 7.8, 12), "timeDate") alpos@time.zone <- "JST" positions(a)@time.zone <- "PST" align(a, alpos, matchtol = 1, localzone = T) align(a, matchtol=1, localzone=T, by="days", k.by=2)