[R-SIG-Finance] xts - Is there a quick and dirty way tomanually edit an xts object ?

jeff.a.ryan at gmail.com jeff.a.ryan at gmail.com
Sun May 16 22:14:26 CEST 2010

I am not too sure what needs you have in terms of editing, but one last comment to consider.  

To further complicate, the internal index of an xts object is not what you see with "index()". It is actually the numeric, which gets converted into something time based upon extraction and printing. The internals of xts are very much intended with high_performance in mind, so manually manipulating can get you into trouble if you don't watch out. 

str(unclass(x)) would give you a decent idea of the problem. 

Standard accessor method for [<-.xts and index<-.xts should really be all you need. 

Sent via BlackBerry from T-Mobile

-----Original Message-----
From: Dirk Eddelbuettel <edd at debian.org>
Date: Sun, 16 May 2010 13:36:39 
To: <me at censix.com>
Cc: <r-sig-finance at stat.math.ethz.ch>
Subject: Re: [R-SIG-Finance] xts - Is there a quick and dirty way to
 manually edit an xts object ?

On 16 May 2010 at 20:19, me at censix.com wrote:
| Hi to the list. I am looking for a fast way to manually edit an xts object
| in R, i.e. by using the de(..) function. See example.
| require(xts)
| require(quantmod)
| getSymbols("YHOO")
| is.xts(YHOO) #TRUE
| edited<-de(YHOO) # Does not work
| edited<-de(as.matrix(YHOO)) # Does work for the values, but the date index
| is not editable. Is there a (quick) way to edit the full xts object ?

Tough because 

   R> head(index(YHOO))
   [1] "2007-01-03" "2007-01-04" "2007-01-05" "2007-01-08" "2007-01-09" "2007-01-10"
   R> head(as.numeric(index(YHOO)))
   [1] 13516 13517 13518 13521 13522 13523

Dates are integers; intra-daily POSIXct is floats.  Not really stuff you'd
want to edit.  You your problem is that 'what you see is NOT what you got' --
consider the first date which is printed (ie format()'ed) as 2007-01-03 but
stored as 13516.

I think you may want to write a helper function instead:

  decompose an xts in payload and index
  edit either or both
  stick it back together

and iterate til you are happy.

  Regards, Dirk

R-SIG-Finance at stat.math.ethz.ch mailing list
-- 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.

More information about the R-SIG-Finance mailing list