[R-SIG-Finance] selecting specific rows from an xts object

David Reiner David.Reiner at xrtrading.com
Mon Dec 15 16:33:10 CET 2014


If you include the date, or use fractional seconds to create an interval, it should work.
xts uses half open/half closed intervals so ["T09:30:00/T09:30:00"] is empty.

> (nobj <- xts(1:5, as.POSIXct('2014-12-15 09:30')+(-2):2))
                    [,1]
2014-12-15 09:29:58    1
2014-12-15 09:29:59    2
2014-12-15 09:30:00    3
2014-12-15 09:30:01    4
2014-12-15 09:30:02    5
> nobj["2014-12-15 09:30:00"]
                    [,1]
2014-12-15 09:30:00    3
> nobj["T09:29:59.5/T09:30:00.5"]
                    [,1]
2014-12-15 09:30:00    3
HTH,
-- David


-----Original Message-----
From: R-SIG-Finance [mailto:r-sig-finance-bounces at r-project.org] On Behalf Of Robert Schien
Sent: Monday, December 15, 2014 8:32 AM
To: r-sig-finance at r-project.org
Subject: [R-SIG-Finance] selecting specific rows from an xts object


Hello,

I have a questions concerning the xts package.

How can I select rows for specific times from a xts series?
I know tthat one select a range with the help of "T", for example
x["T09:30:00/T09:40:00"]

But how can I select only the rows an 09:30:00 ?
x["T09:30:00/T09:30:00"] does not work. This delivers the
whole time series.
x["T09:30:00"] does not work, too. It delivers no rows at all.

So, how can I do, what I want?
I didn't find anything in the xts documentation.

Thank you in advance.

Greetings
Robert

_______________________________________________
R-SIG-Finance at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.


This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws.  Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.

THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND.  TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.



More information about the R-SIG-Finance mailing list