Thanks Jeff for the detailed explanations as always.
setOldClass("xts") helps me get rid of the warnings.

I am a little curious on your functional closures design plan. I know
functional language such as OCaml or kdb+ are good for time series
calcualtions. R seems also kind of functional language. But what will be the
role of closures in quantmod or xts? Would you please reveal some of the
functional closures design in plain English for mortals like me? :)

And what's your suggestion if I want to define a new class? Before S5? The
slots of the class would be mainly xts.

Regards,
Wind




On Tue, Oct 27, 2009 at 11:29 PM, Jeff Ryan <jeff.a.ryan@gmail.com> wrote:

> In fact zoo doesn't work for me by default.  I think the issue is that
> quantmod calls setOldClass for you (to use S3 as S4 slots).
>
> library(zoo)
> setClass("trader",representation(prices="zoo",indicator="zoo"))
>
> [1] "trader"
> Warning message:
> In .completeClassSlots(ClassDef, where) :
>  undefined slot classes in definition of "trader": prices(class
> "zoo"), indicator(class "zoo")
>
>
> Keeping the environment as clean as possibly (don't attach other
> packages that can change the game) is the best way to find the issue.
>
> library(xts)
> setClass("trader",representation(prices="xts",indicator="xts"))
>
> [1] "trader"
> Warning message:
> In .completeClassSlots(ClassDef, where) :
>  undefined slot classes in definition of "trader": prices(class
> "xts"), indicator(class "xts")
>
>
> # have to call setOldClass ... this really should be setS3Class IMO,
> as "Old" implies bad...
>
> setOldClass("xts")
> setClass("trader",representation(prices="xts",indicator="xts"))
> [1] "trader"
>
> getClass("trader")
> Class "trader" [in ".GlobalEnv"]
>
> Slots:
>
> Name:     prices indicator
> Class:       xts       xts
>
> As may be evident from my previous work, I'd petition you not to use
> S4 classes until S5 comes out ;)  quantmod is in the process of
> removing all S4 objects, instead migrating to more powerful (though
> slightly less OO style in some sense) functional closures.  Yes
> _functional closures_...
>
> One other point, the newest xts_0.6-8 from CRAN should be used now, as
> there were some major improvements and bug fixes implemented in the
> release.
>
> Best,
> Jeff
>
> On Tue, Oct 27, 2009 at 5:22 AM, Wind <windspeedo99@gmail.com> wrote:
> > I wonder how to  use xts in setClass().   It seems that zoo is OK.
> > Thanks.
> >
> > Wind
> >
> >
> >> library(quantmod)
> > Loading required package: xts
> > Loading required package: zoo
> >
> > Attaching package: 'zoo'
> >
> >
> > The following object(s) are masked from package:base :
> >
> >  as.Date.numeric
> >
> > xts now requires a valid TZ environment variable to be set
> >  your current TZ:CST-8
> > Loading required package: Defaults
> > Loading required package: TTR
> >> setClass("trader",representation(prices="zoo",indicator="zoo"))
> > [1] "trader"
> >> setClass("trader",representation(prices="xts",indicator="xts"))
> > [1] "trader"
> > Warning message:
> > In .completeClassSlots(ClassDef, where) :
> >  undefined slot classes in definition of "trader": prices(class "xts"),
> > indicator(class "xts")
> >
> >> sessionInfo()
> > R version 2.9.2 (2009-08-24)
> > i386-pc-mingw32
> >
> > locale:
> > LC_COLLATE=Chinese (Simplified)_People's Republic of
> > China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
> > China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
> > China.936;LC_NUMERIC=C;LC_TIME=English_United States.1252
> >
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> > other attached packages:
> > [1] quantmod_0.3-11 TTR_0.20-1      Defaults_1.1-1  xts_0.6-7
> > [5] zoo_1.5-8
> >
> > loaded via a namespace (and not attached):
> > [1] grid_2.9.2      lattice_0.17-25
> >>
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-SIG-Finance@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only.
> > -- If you want to post, subscribe first.
> >
>
>
>
> --
> Jeffrey Ryan
> jeffrey.ryan@insightalgo.com
>
> ia: insight algorithmics
> www.insightalgo.com
>

	[[alternative HTML version deleted]]

