[Rd] Problem with S4 inheritance: unexpected re-initialization?
cstrato
cstrato at aon.at
Sat Mar 31 19:56:34 CEST 2007
Dear all,
To explain my problem I am attaching a demonstration package "myclasspkg":
I have the following two S4 classes with similar inheritance:
SubSubClassA <- SubClassB <- BaseClass
SubSubClassB <- SubClassB <- BaseClass
In R I am calling the following functions:
> library(myclasspkg)
> subA <-
new("SubClassA",filename="OutSubA",filedir="/Volumes/CoreData/CRAN/Workspaces/rclasspkg",mytitle="TitleSubA")
> subsubA <-
new("SubSubClassA",filename="MyFileName",filedir="/Volumes/CoreData/CRAN/Workspaces/rclasspkg",subA=subA)
> subsubB <-
new("SubSubClassB",filename="MyFileNameB",filedir="/Volumes/CoreData/CRAN/Workspaces/rclasspkg",subA=subA)
Creating subsubA works fine and gives the correct result:
> subsubA <-
new("SubSubClassA",filename="MyFileName",filedir="/Volumes/CoreData/CRAN/Workspaces/rclasspkg",subA=subA)
[1] "------initialize:SubSubClassA------"
[1] "SubSubClassA:init:class(.Object) = SubSubClassA"
[1] "------initialize:SubClassB------"
[1] "SubClassB:init:class(.Object) = SubSubClassA"
[1] "------initialize:BaseClass------"
[1] "BaseClass:init:class(.Object) = SubSubClassA"
[1] "------pathFile------"
[1] "BaseClass:init:dirfile =
/Volumes/CoreData/CRAN/Workspaces/rclasspkg/MyFileName"
[1] "------setValidity:BaseClass------"
[1] "BaseClass:val:class(object) = SubClassB"
[1] "BaseClass:val:dirfile =
/Volumes/CoreData/CRAN/Workspaces/rclasspkg/MyFileName"
[1] "BaseClass:val:filedir = /Volumes/CoreData/CRAN/Workspaces/rclasspkg"
[1] "------setValidity:SubClassB------"
[1] "SubClassB:val:class(object) = SubClassB"
[1] "SubClassB:val:filename = MyFileName"
[1] "BaseClass:val:dirfile =
/Volumes/CoreData/CRAN/Workspaces/rclasspkg/MyFileName"
[1] "------setValidity:SubSubClassA------"
[1] "SubSubClassA:val:class(.Object) = SubSubClassA"
In contrast, when trying to create subsubB, it seems that setValidity
re-initializes SubClassB:
> subsubB <-
new("SubSubClassB",filename="MyFileNameB",filedir="/Volumes/CoreData/CRAN/Workspaces/rclasspkg",subA=subA)
[1] "------initialize:SubSubClassB------"
[1] "SubSubClassB:init:class(.Object) = SubSubClassB"
[1] "SubSubClassB:init:subsubnameB = subsubNameB"
[1] "------initialize:SubClassB------"
[1] "SubClassB:init:class(.Object) = SubSubClassB"
[1] "------initialize:BaseClass------"
[1] "BaseClass:init:class(.Object) = SubSubClassB"
[1] "------pathFile------"
[1] "BaseClass:init:dirfile =
/Volumes/CoreData/CRAN/Workspaces/rclasspkg/MyFileNameB"
[1] "------setValidity:BaseClass------"
[1] "------initialize:SubClassB------"
[1] "SubClassB:init:class(.Object) = SubClassB"
[1] "------initialize:BaseClass------"
[1] "BaseClass:init:class(.Object) = SubClassB"
[1] "------pathFile------"
Error in if (dirname(filename) != ".") { :
argument is of length zero
Can someone tell me why the first case works fine, but the second case not?
Probably, I am making some mistake, but since two weeks I am unable to
find it.
Thank you in advance.
P.S.: I am running R-2.5.0 on Intel-Mac OS 10.4.8.
Best regards
Christian
_._._._._._._._._._._._._._._._
C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
V.i.e.n.n.a A.u.s.t.r.i.a
_._._._._._._._._._._._._._._._
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myclasspkg_0.1.1.tar.gz
Type: application/x-gzip
Size: 5160 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-devel/attachments/20070331/06308a2d/attachment.gz
More information about the R-devel
mailing list