Friends I have an xts that I wish to access. Browse[2]> DATA.ba[[p]]["2012-03-20 00:59:57","bid"] bid 2012-03-20 00:59:57 1.4993 So far so good. Now putting the index into a variable: Browse[2]> Time [1] "2012-03-20 00:59:57 NZDT" Browse[2]> DATA.ba[[p]][Time, "bid"] bid Where has it gone? Looking closer.... Browse[2]> index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]) [1] "2012-03-20 00:59:57 NZDT" Browse[2]> Browse[2]> Time [1] "2012-03-20 00:59:57 NZDT" Browse[2]> Browse[2]> index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]) == Time [1] FALSE Browse[2]> Browse[2]> class(Time) [1] "POSIXct" "POSIXt" Browse[2]> class(index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"])) [1] "POSIXct" "POSIXt" So the variable 'Time' should be good to index DATA.ba[[p]]. I am hopelessly confused. cheers Worik [[alternative HTML version deleted]]
I see "NZDT" going in and out of your time values. Could that have something to do with it? On Mar 25, 2012, at 10:15 , Worik R wrote:> Friends > > I have an xts that I wish to access. > > Browse[2]> DATA.ba[[p]]["2012-03-20 00:59:57","bid"] > bid > 2012-03-20 00:59:57 1.4993 > > So far so good. > > Now putting the index into a variable: > > Browse[2]> Time > [1] "2012-03-20 00:59:57 NZDT" > Browse[2]> DATA.ba[[p]][Time, "bid"] > bid > > Where has it gone? > > > Looking closer.... > > > Browse[2]> index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]) > [1] "2012-03-20 00:59:57 NZDT" > Browse[2]> > > Browse[2]> Time > [1] "2012-03-20 00:59:57 NZDT" > Browse[2]> > > Browse[2]> index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]) == Time > [1] FALSE > Browse[2]> > > Browse[2]> class(Time) > [1] "POSIXct" "POSIXt" > > Browse[2]> class(index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"])) > [1] "POSIXct" "POSIXt" > > So the variable 'Time' should be good to index DATA.ba[[p]]. I am > hopelessly confused. > > cheers > Worik > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
On Sun, Mar 25, 2012 at 3:15 AM, Worik R <worikr at gmail.com> wrote:> Friends > > I have an xts that I wish to access. > > Browse[2]> DATA.ba[[p]]["2012-03-20 00:59:57","bid"] > ? ? ? ? ? ? ? ? ? ? ? bid > 2012-03-20 00:59:57 1.4993 > > So far so good. > > Now putting the index into a variable: > > Browse[2]> Time > [1] "2012-03-20 00:59:57 NZDT" > Browse[2]> DATA.ba[[p]][Time, "bid"] > ? ? bid > > Where has it gone? >It's hard to say, especially since you give no indication how you assigned the value to Time. A reproducible example, as requested in the posting guide, would be helpful. Also, what version of R, xts, and zoo are you using?> > Looking closer.... > > > Browse[2]> index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]) > [1] "2012-03-20 00:59:57 NZDT" > Browse[2]> > > Browse[2]> Time > [1] "2012-03-20 00:59:57 NZDT" > Browse[2]> > > Browse[2]> index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]) == Time > [1] FALSE > Browse[2]> > > Browse[2]> class(Time) > [1] "POSIXct" "POSIXt" > > Browse[2]> class(index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"])) > [1] "POSIXct" "POSIXt" > > So the variable 'Time' should be good to index DATA.ba[[p]]. ?I am > hopelessly confused. >The printed representation of the index value and class cannot be used to accurately determine equality.> cheers > Worik >-- Joshua Ulrich | FOSS Trading: www.fosstrading.com R/Finance 2012: Applied Finance with R www.RinFinance.com