Accessing "row names" in an object created by quantmod

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing "row names" in an object created by quantmod

Fisher Dennis
R 3.4.1
OS X

Colleagues,

I am just learning about quantmod and I don’t understand the behavior of xts objects.

For example:
        getSymbols("AAPL”)
Creates an object AAPL

        tail(AAPL)
yields:
           AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
2017-08-31    163.64    164.52   163.48     164.00    26785100        164.00
2017-09-01    164.80    164.94   163.63     164.05    16591100        164.05
2017-09-05    163.75    164.25   160.56     162.08    29468500        162.08
2017-09-06    162.71    162.99   160.52     161.91    21651700        161.91
2017-09-07    162.09    162.24   160.36     161.26    21928500        161.26
2017-09-08    160.86    161.15   158.53     158.63    28352600        158.63

I would like to extract a row based on the date column.  The usual approaches (e.g., rownames) do not work.  

So, how do I extract the date column?

Dennis


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing "row names" in an object created by quantmod

Ilya Kipnis
The command is index(AAPL)

On Tue, Sep 12, 2017 at 10:42 AM, Dennis Fisher <[hidden email]>
wrote:

> R 3.4.1
> OS X
>
> Colleagues,
>
> I am just learning about quantmod and I don’t understand the behavior of
> xts objects.
>
> For example:
>         getSymbols("AAPL”)
> Creates an object AAPL
>
>         tail(AAPL)
> yields:
>            AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume
> AAPL.Adjusted
> 2017-08-31    163.64    164.52   163.48     164.00    26785100
> 164.00
> 2017-09-01    164.80    164.94   163.63     164.05    16591100
> 164.05
> 2017-09-05    163.75    164.25   160.56     162.08    29468500
> 162.08
> 2017-09-06    162.71    162.99   160.52     161.91    21651700
> 161.91
> 2017-09-07    162.09    162.24   160.36     161.26    21928500
> 161.26
> 2017-09-08    160.86    161.15   158.53     158.63    28352600
> 158.63
>
> I would like to extract a row based on the date column.  The usual
> approaches (e.g., rownames) do not work.
>
> So, how do I extract the date column?
>
> Dennis
>
>
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone / Fax: 1-866-PLessThan (1-866-753-7784)
> www.PLessThan.com
>
> _______________________________________________
> [hidden email] 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.

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing "row names" in an object created by quantmod

braverock
In reply to this post by Fisher Dennis
Ilya has already pointed out the index function.

Slightly more information is that xts objects don't have row names,
they have a time/date based index, and facilities to subset using that
index.  For the most part, you can do this as you would with a
data.frame, by exact index or by row number, but there are also many
other things that you can do as well.

I suggest taking a close look at the xts FAQ:

https://joshuaulrich.github.io/xts/xts_faq.html

Regards,

Brian
 

On Tue, 2017-09-12 at 07:42 -0700, Dennis Fisher wrote:

> R 3.4.1 
> OS X
>
> Colleagues,
>
> I am just learning about quantmod and I don’t understand the behavior
> of xts objects.
>
> For example:
> getSymbols("AAPL”)
> Creates an object AAPL
>
> tail(AAPL)
> yields:
>            AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume
> AAPL.Adjusted
> 2017-08-
> 31    163.64    164.52   163.48     164.00    26785100        164.00
> 2017-09-
> 01    164.80    164.94   163.63     164.05    16591100        164.05
> 2017-09-
> 05    163.75    164.25   160.56     162.08    29468500        162.08
> 2017-09-
> 06    162.71    162.99   160.52     161.91    21651700        161.91
> 2017-09-
> 07    162.09    162.24   160.36     161.26    21928500        161.26
> 2017-09-
> 08    160.86    161.15   158.53     158.63    28352600        158.63
>
> I would like to extract a row based on the date column.  The usual
> approaches (e.g., rownames) do not work.  
>
> So, how do I extract the date column?
>
> Dennis
>
>
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone / Fax: 1-866-PLessThan (1-866-753-7784)
> www.PLessThan.com
>
> _______________________________________________
> [hidden email] 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.
>

_______________________________________________
[hidden email] 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.