## create an artificial 'timeSeries' object
setRmetricsOptions(myFinCenter = "GMT")
charvec = timeCalendar()
set.seed(4711)
data = matrix(exp(cumsum(rnorm(12, sd = 0.1))))
TS = timeSeries(data, charvec, units = "TS")
TS
## mathematical operations: | +/- * ^ ...
TS^2
TS[2:4]
OR = returns(TS)
OR
OR > 0
## median, quantile
median(TS)
quantile(TS)
TS[3] <- NA # to demonstrate 'na.rm'
median(TS) # NA
#quantile(TS) # error
median(TS, na.rm = TRUE)
quantile(TS, na.rm = TRUE)
Run the code above in your browser using DataLab