[datatable-help] Playing nice(r) with S4?

Matthew Dowle mdowle at mdowle.plus.com
Thu Nov 25 00:01:31 CET 2010


For the setClass call itself that would be ok, and then use the class
somehow, to test it worked?

setClass("DTS4", representation(info="data.table"))
test(228, is.data.table(new("DTS4")))


On Wed, 2010-11-24 at 14:26 -0500, Steve Lianoglou wrote:
> Hi,
> 
> On Wed, Nov 24, 2010 at 2:13 PM, Matthew Dowle <mdowle at mdowle.plus.com> wrote:
> > Try
> >
> >  test(228, setClass("DTS4", representation(info="data.table")), "DTS4")
> 
> I tried that at first, but you get an error from (I think) defining a
> new class in the wrong place, specifically:
> 
> Test 228 Error in assign(mname, def, where) :
>   cannot add bindings to a locked environment
> 
> > In test.data.table we only use try() for when the correct result is an
> > error and the test is that we get the right error message with a grep in
> > another test just afterwards. Otherwise we can leave test() to try().
> >
> > Code that shouldn't fail can just be written (and would cause
> > test.data.table to stop then and there on error) or inside a test().
> 
> So, in light of the above problem, would you rather I just write the
> code that defines the new S4 class and not test that "it worked" since
> we assume implicitly it works if no error stops test.data.table() form
> completing?
> 
> -steve
> 




More information about the datatable-help mailing list