[R-SIG-Finance] "xts" as S4 slot class

Jeffrey Ryan jeffrey.ryan at lemnica.com
Fri Oct 28 16:09:12 CEST 2011


Hi Stanley,

S4 isn't a great idea in my (vocal) opinion.  I ask that you rethink
the decision on why it seems appropriate for you to use.

99.99% of R programming is perfect with S3 + attributes.  And I am
being generous w.r.t. the 0.01%.

That said, you should read the errors that you get and take a look at
the constantly moving/difficult to follow trajectory of S4
documentation.

> setClass("data", representation(data="xts"))
[1] "data"
Warning message:
undefined slot classes in definition of "data": data(class "xts")
> setOldClass("xts")
> setClass("data", representation(data="xts"))
[1] "data"
> d <- new("data", data=xts())
> d
An object of class "data"
Slot "data":
Data:
numeric(0)

Index:
integer(0)

>

The trick is setOldClass.  Obviously a pejorative name, as if 'old'
implies bad.  What it should be aliased to is
setPerfectlyPerfectClassIntoNewStillBrewingS4mess()

;-)

Partial joking aside, what makes S4 a requirement here?  Are you
looking for additional obscurity or complexity?

Best,
Jeff

On Fri, Oct 28, 2011 at 8:09 AM, Stanley Chu <chd850 at gmail.com> wrote:
> Hi guys,
>
> I am trying to set my slot class to be "xts", and am having some problems. Does anyone know what to do to make this work?
>
> setClass("data", representation(data  = "xts"))
> new("data", data = xts())
>
> Thanks,
> Stanley
>
> _______________________________________________
> 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.
>



-- 
Jeffrey Ryan
jeffrey.ryan at lemnica.com

www.lemnica.com
www.esotericR.com



More information about the R-SIG-Finance mailing list