Skip to content

using [ on xts object

5 messages · financial engineer, Joshua Ulrich

#
Dear Mr. or Mrs. Engineer,

On Fri, Dec 23, 2011 at 1:50 PM, financial engineer
<fin_engr at hotmail.com> wrote:
You can't.  You created an xts object with a Date class index.  The
Date class doesn't contain any information about time of day.  Use a
date/time class (read ?DateTimeClasses).

Subsetting xts objects by time of day has been discussed several times
on this list.  Please search the list archives (e.g. via rseek.org).

Regards,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
#
On Fri, Dec 23, 2011 at 3:17 PM, financial engineer
<fin_engr at hotmail.com> wrote:
Errors, plural.

1) You cbind the "date" and "time" columns into a _matrix_ dt.  Then
you try to extract the index(dt) of the matrix.  Matrix class objects
don't have an index attribute.
2) You pass a matrix to strptime.  ?strptime says "strptime converts
character _vectors_ to class POSIXlt" (emphasis added).
3) Even if you didn't make the first two errors, you use as.Date() to
effectively remove the time component you set out to add.

My intent isn't to be rude.  These 'issues' are the result of not
understanding some very basic concepts.  Doing the work for you and
giving you the answer won't help you in the long-term.  So, take a
step back and examine the results of the individual commands to find
where the output isn't what you expect.  Then read the documentation
to find out why.
Regards,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com