its (version 1.0.3)

itsSubset: Range and Extract for Irregular Time-Series Objects

Description

Range and extract for objects of class "its".

Usage

rangeIts(x,start=dates(x)[1],end=dates(x)[nrow(x)],format=its.format(),...)
extractIts(x,weekday=FALSE,find=c("all","last","first"),period=c("week","month"),partials=TRUE,select)
x[i,j,dates]

Arguments

x
an object of class "its"
start, end
POSIXct or character representation of the start or end time-stamp, if character, then the format is as specified by the argument format
format
format of "start" and "end" dates, see format.POSIXct.
i,j
indices specifying the parts to be extracted from the irregular time-series object
dates
POSIX dates specifying the timestamps of rows to be extracted from the irregular time-series object
...
further arguments passed to as.POSIXct
weekday
logical, defines whether only weekdays are to be returned
find
to find the first, last, or all samples within each period
period
the period within which 'find' and/or 'select' operate
partials
defines whether the first (possibly incomplete) period is processed for find=first, and whether the last is processed for find=last
select
an integer vector defining one or more days to select. The integer specifies wday (for period=week) or mday (for period=month). See as.POSIXlt

Value

  • An object of class "its".

Details

rangeIts selects a range of rows that fall between two times, specified in text format. extractIts selects a subset of rows that obey some sort of semi-regular rule such as monthends, weekdays, and so on. The order of application is weekday, find, then select. x[i,j,dates] extractor method for an irregular time-series: i and dates are mutually exclusive alternatives for specifying rows. It proceeds as for a matrix, with the exception that drop=FALSE is enforced, so the result always inherits from matrix.

See Also

ts, POSIXct, itsFile, itsLags, itsJoin, itsTimes, itsSubset, itsFin, itsDisp, itsInfo, itsCumdif, itsArith itsInterp

Examples

Run this code
its.format("%Y-%m-%d")
b <- newIts(start="2003-01-01",end="2003-01-20")
rangeIts(b,start = "2003-01-05" ,end= "2003-01-15")
rangeIts(b,start = ISOdate(2003,1,5,hour=0) ,end= ISOdate(2003,1,15,hour=0))
b[1:3,]
b[,1]
b[,dates=ISOdate(2003,1,1,hour=0)]
its.format("%a %d %b %Y")
c <- newIts()
extractIts(c,weekday=TRUE,period="month",find="last")  #the last weekdays of the month in c

Run the code above in your browser using DataCamp Workspace