Extending STIDF class : cannot creat an empty STIDF object

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Extending STIDF class : cannot creat an empty STIDF object

scizmeli
Hello everyone,

Greetings to the r-sig-geo community.

I would like to extend the STIDF class :
setClass("newClass1",contains="STIDF", representation(myslot="numeric"),prototype=prototype(myslot=numeric()))
setClass("newClass2",representation(first="newClass1",second="newClass1",third="newClass1"))

But a new empty newClass1 class created with the new() function does not pass the validObject() test:
validObject(new("newClass1"))
Error in checkSlotAssignment(object, name, value) :
                assignment of an object of class “NULL” is not valid for slot ‘time’ in an object of class “STIDF”; is(value, "xts") is not TRUE

Tracking down the error, I could come to :
validObject(new("STIDF"))
Error in checkSlotAssignment(object, name, value) :
                assignment of an object of class “NULL” is not valid for slot ‘time’ in an object of class “STI”; is(value, "xts") is not TRUE

I need to be able to pass the test validObject(new("STIDF")) because my newClass2 should be able to contain empty newClass1 slots. For now, it is not possible!

Is this a bug?
Servet
Reply | Threaded
Open this post in threaded view
|

Re: Extending STIDF class : cannot creat an empty STIDF object

edzer


On 06/19/2013 06:55 PM, scizmeli wrote:

> Hello everyone,
>
> Greetings to the r-sig-geo community.
>
> I would like to extend the STIDF class :
> setClass("newClass1",contains="STIDF",
> representation(myslot="numeric"),prototype=prototype(myslot=numeric()))
> setClass("newClass2",representation(first="newClass1",second="newClass1",third="newClass1"))
>
> But a new empty newClass1 class created with the new() function does not
> pass the validObject() test:
> validObject(new("newClass1"))
> Error in checkSlotAssignment(object, name, value) :
> assignment of an object of class “NULL” is not valid for slot ‘time’ in an
> object of class “STIDF”; is(value, "xts") is not TRUE
>
> Tracking down the error, I could come to :
> validObject(new("STIDF"))
> Error in checkSlotAssignment(object, name, value) :
> assignment of an object of class “NULL” is not valid for slot ‘time’ in an
> object of class “STI”; is(value, "xts") is not TRUE
>
> I need to be able to pass the test validObject(new("STIDF")) because my
> newClass2 should be able to contain empty newClass1 slots. For now, it is
> not possible!
>
> Is this a bug?

No, this is intentional.

> Servet
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Extending-STIDF-class-cannot-creat-an-empty-STIDF-object-tp7583841.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Extending STIDF class : cannot creat an empty STIDF object

scizmeli
Thank you for your reply, Edzer,

I am not very profficient at R OO programming so If you don't mind, can you then suggest me a way to deal with the situation? My second class sometimes does not have data, I need to be able to create objects inherited from an emtpy STIDF class.

any suggestions?