[R-SIG-Finance] about an error of xts

Brian G. Peterson brian at braverock.com
Sun Apr 29 13:22:05 CEST 2012


Here's my sessionInfo on one machine.

> sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods
base     

other attached packages:
[1] quantmod_0.3-17 TTR_0.20-3      xts_0.8-3       zoo_1.7-4      
[5] Defaults_1.1-1 

loaded via a namespace (and not attached):
[1] grid_2.15.0    lattice_0.20-0


So try upgrading to modern versions of everything.  I can't reproduce
under R 2.14.2 either.

On Sun, 2012-04-29 at 13:29 +0800, Haiping LAN wrote:
> *Dear Brian.*
> *That's why i feel strange for this issue.*
> *I know you cannot reproduce relevant error information, which is quite
> similar to some report in stackoverflow.*
> http://stackoverflow.com/questions/9757430/xts-error-order-by-requires-an-appropriate-time-based-object
> 
> 
> Probably,  you can give me other hints , such as release version, os, et al.
> 
> Thank you very much.
> 
> Best,
> 
> Haiping
> 
> 
> On 28 April 2012 18:31, Brian G. Peterson <brian at braverock.com> wrote:
> 
> > On Sat, 2012-04-28 at 16:14 +0800, Haiping LAN wrote:
> > > Dear Brian,  Michael  and Db.
> > >
> > > Thanks for all your suggests.
> > > I tried all your hints. But i found the problem remains, and still shows
> > "
> > > order.by requires an appropriate time-based object"
> > >
> > > it sounds strange.
> >
> > If you are going to persist in suggesting that a bug exists, then please
> > provide a reproducible example.
> >
> > >From your original message and the suggestions you've received, the
> > complete example would be:
> >
> > #########
> > require(quantmod)
> > getSymbols('^GSPC')
> >
> > ex.model <- specifyModel(T.ind(GSPC) ~ Delt(Cly,k=1:3))
> >
> > T.ind <- function(quotes,tgt.margin=0.025,n.days=10) {
> >  v <- apply(HLC(quotes),1,mean)
> >  r <- matrix(NA,ncol=n.days,nrow=NROW(quotes))
> >  for(x in 1:n.days) r[,x] <- Next(Delt(v,k=x),x)
> >  x <- apply(r,1,function(x) sum(x[x > tgt.margin | x < -tgt.margin]))
> >  if (is.xts(quotes)) xts(x,time(quotes)) else x
> > }
> >
> > ex.model.Cl <- specifyModel(T.ind(GSPC) ~ Delt(Cl(GSPC),k=1:3))
> > ex.model.Ad <- specifyModel(T.ind(GSPC) ~ Delt(Ad(GSPC),k=1:3))
> > #########
> >
> > This works for me.
> >
> > Where, specifically, do you think there is still a problem?
> >
> > I don't see any evidence of a bug here in quantmod, xts, or lm.
> >
> >   - Brian
> >
> > > On 23 April 2012 23:08, Brian G. Peterson <brian at braverock.com> wrote:
> > >
> > > > On Mon, 2012-04-23 at 11:03 -0400, R. Michael Weylandt wrote:
> > > > > In addition to what's been said, you could much more easily write:
> > > > >
> > > > > GSPC <- getSymbols("^GSPC", from = "2000-01-01", auto.assign = F)
> > > >
> > > > I'll make it simpler still...
> > > >
> > > > getSymbols("^GSPC", from = "2000-01-01")
> > > >
> > > > which will create object 'GSPC' and avoids the frowned upon use of 'F'
> > > > for FALSE (which can easily collide with a variable)
> > > >
> > > > Regards,
> > > >
> > > >   - Brian
> >
> >
> 
> 

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list