Basic functions related to irregular time-series objects.

daysecond(object, tz = "GMT")
approx.irts(object, time, ...)
is.businessday(object, tz = "GMT")
is.weekend(object, tz = "GMT")
read.irts(file, format = "%Y-%m-%d %H:%M:%S", tz = "GMT", ...)
weekday(object, tz = "GMT")
write.irts(object, file = "", append = FALSE, quote = FALSE,
           sep = " ", eol = "\n", na = "NA", dec = ".",
           row.names = FALSE, col.names = FALSE, qmethod = "escape",
           format = "%Y-%m-%d %H:%M:%S", tz = "GMT", usetz = FALSE,
           format.value = NULL, ...)

Arguments

object

an object of class "irts"; usually, a result of a call to irts.

format, tz, usetz

formatting related arguments, see format.POSIXct.

time

an object of class "POSIXct" specifying the times at which to interpolate the irregularly spaced time-series.

file, append, quote, sep, eol, na, dec, row.names, col.names, qmethod

reading and writing related arguments, see read.table and write.table.

format.value

a string which specifies the formatting of the values when writing an irregular time-series object to a file. format.value is passed unchanged as argument format to the function formatC.

...

further arguments passed to or from other methods: for approx.irts passed to approx; for read.irts passed to read.table; for write.irts passed to data.frame.

Details

daysecond and weekday return the number of seconds since midnight (the same day) and the weekday as a decimal number (0-6, Sunday is 0), respectively.

is.businessday and is.weekend test which entries of an irregular time-series object are recorded on business days and weekends, respectively.

approx.irts interpolates an irregularly spaced time-series at prespecified times.

read.irts is the function to read irregular time-series objects from a file.

write.irts is the function to write irregular time-series objects to a file.

Value

For daysecond and weekday a vector of decimal numbers representing the number of seconds and the weekday, respectively.

For is.businessday and is.weekend a vector of "logical" representing the test results for each time.

For approx.irts, read.irts and write.irts an object of class "irts".

Author

A. Trapletti

See also

Examples

n <- 10
t <- cumsum(rexp(n, rate = 0.1))
v <- rnorm(n)
x <- irts(t, v)

daysecond(x)
#>  [1]   0.6278049   1.5793434   6.9160924  48.0616426  48.5056538  59.1402733
#>  [7]  60.7583566  84.0186568 100.9838022 104.0421533
weekday(x)
#>  [1] 4 4 4 4 4 4 4 4 4 4
is.businessday(x)
#>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
is.weekend(x)
#>  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
x
#> 1970-01-01 00:00:00 GMT 0.5947
#> 1970-01-01 00:00:01 GMT 1.039
#> 1970-01-01 00:00:06 GMT -1.279
#> 1970-01-01 00:00:48 GMT -0.32
#> 1970-01-01 00:00:48 GMT -1.873
#> 1970-01-01 00:00:59 GMT 0.09132
#> 1970-01-01 00:01:00 GMT 0.7124
#> 1970-01-01 00:01:24 GMT -0.1101
#> 1970-01-01 00:01:40 GMT -1.052
#> 1970-01-01 00:01:44 GMT -0.8914

approx.irts(x, seq(ISOdatetime(1970, 1, 1, 0, 0, 0, tz = "GMT"),
            by = "10 secs", length.out = 7), rule = 2)
#> 1970-01-01 00:00:00 GMT 0.5947
#> 1970-01-01 00:00:10 GMT -1.207
#> 1970-01-01 00:00:20 GMT -0.9739
#> 1970-01-01 00:00:30 GMT -0.7409
#> 1970-01-01 00:00:40 GMT -0.5078
#> 1970-01-01 00:00:50 GMT -1.597
#> 1970-01-01 00:01:00 GMT 0.4213

if (FALSE) { # \dontrun{
file <- tempfile()

# To write an irregular time-series object to a file one might use
write.irts(x, file = file)

# To read an irregular time-series object from a file one might use
read.irts(file = file)

unlink(file)
} # }