[R] fBasics question: Get dates corresponding to maximum values
Neuro LeSuperHéros
neuro3000 at hotmail.com
Fri Apr 22 14:41:16 CEST 2005
fBasics question: Get maximum dates
Hello,
This two series data set has been created with the timeSeries() function
from fBasics
>str(total)
Formal class 'timeSeries' [package "fBasics"] with 7 slots
..@ Data : num [1:262, 1:2] 8703 8603 8573 8680 8668 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:262] "2004-04-19 01:00:00" "2004-04-20 01:00:00"
"2004-04-21 01:00:00" "2004-04-22 01:00:00" ...
.. .. ..$ : chr [1:2] "TS.1" "TS.2"
..@ positions : chr [1:262] "2004-04-19 01:00:00" "2004-04-20 01:00:00"
"2004-04-21 01:00:00" "2004-04-22 01:00:00" ...
..@ format : chr "%Y-%m-%d %H:%M:%S"
..@ FinCenter : chr "London"
..@ units : chr [1:2] "TS.1" "TS.2"
..@ title : chr "Time Series Object"
..@ documentation: chr "Created at London 2005-04-22 12:54:36"
Here are the first three lines:
>total[1:3,]
TS.1 TS.2
2004-04-19 01:00:00 8702.82 55.18
2004-04-20 01:00:00 8602.98 48.48
2004-04-21 01:00:00 8573.05 46.65
I managed to get the maximum for each series:
>maxima<-c(max(total at Data[,1]), max(total at Data[,2]))
>maxima
[1] 9927.20 83.11
But now, I'd like to get the CORRESPONDING DATES for these maxima.
Another question, is there a way to refer to data as TS.1 or TS.2 in
function instead of total at Data[,1:2]?
Thanks
>version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 1.0
year 2005
month 04
day 18
language R
More information about the R-help
mailing list