Jens Henrik Badsberg
2004-Mar-16 13:21 UTC
SV: [R] Documentation on how to put classes and methods in packageswith namespace?
Re. the Kings Quest game called R, Inspired by the "stats4" of R-1.9.0 (alpha of 2004-03-15) I moved the body af my function ".onLoad.dynamicGraph" to the end of ".../dynamicGraph/R/dynamicGraph" (replacing "library(methods)" by "require(methods)"). The secound run, with [Previously saved workspace restored], produces the same result as in my first letter of today:> library(dynamicGraph)Loading required package: tcltk> b <- DynamicGraph(1:10)Error in getClass(superClass) : "NodeProto" is not a defined class I also (again) read pages 13 and 16-17 (and 73) of "Writing R Extensions" of 2004-03-15, and the manual pages of "setClass": where: For 'setClass' and 'removeClass', the environment in which to store or remove the definition. Defaults to the top-level environment of the calling function (the global environment for ordinary computations, but the environment or namespace of a package when loading that package). For other functions, 'where' defines where to do the search for the class definition, and the default is to search from the top-level environment or namespace of the caller to this function. "setMethod": where: the database in which to store the definition of the method; "isGeneric": where: The environment, namespace, or search-list position from which to search for objects. By default, start at the top-level environment of the calling function, typically the global environment (i.e., use the search list), or the namespace of a package from which the call came. It is important to supply this argument when calling any of these functions indirectly. With package namespaces, the default is likely to be wrong in such calls. It does not help me. Maybe this should be move to "a bug report". Regards, Jens Henrik -----Oprindelig meddelelse----- Fra: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] Sendt: 16. marts 2004 12:37 Til: Jens Henrik Badsberg Cc: r-help at stat.math.ethz.ch Emne: Re: [R] Documentation on how to put classes and methods in packageswith namespace? See `Writing R Extensions' in 1.9.0 alpha and the stats4 package there as an example. At this point you probably only want to check a package against 1.9.0 alpha, anyway. On Tue, 16 Mar 2004, Jens Henrik Badsberg wrote:> > Documentation on how to put classes and methods in packages with namespace? > > How should I define my classes and methods in "dynamicGraph"??? > > (That is - Can some one point me to the documentation on > how to put classes and methods in packages with a namespace? )[...] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Jens Henrik Badsberg
2004-Mar-16 13:32 UTC
SV: [R] Documentation on how to put classes and methods in packageswith namespace?
Please disregard the previous mail. "a bug report" made me test in version 1.9.0 (alpha). Here it works fine, e.i. without changing the version of "dynamicGraph" on CRAN. Regards, Jens Henrik R : Copyright 2004, The R Foundation for Statistical Computing Version 1.9.0 alpha (2004-03-15), ISBN 3-900051-00-3 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored]> search()[1] ".GlobalEnv" "package:stats" "package:graphics" "package:utils" [5] "package:methods" "Autoloads" "package:base"> library(dynamicGraph)Loading required package: tcltk> search()[1] ".GlobalEnv" "package:tcltk" "package:dynamicGraph" [4] "package:stats" "package:graphics" "package:utils" [7] "package:methods" "Autoloads" "package:base"> ls(pos=3, all.names=TRUE)[1] ".__C__BlockEdgeProto" ".__C__BlockProto" [3] ".__C__CanvasProto" ".__C__ContinuousVertexProto" [5] ".__C__defaultModelObjectProto" ".__C__defaultTestObjectProto" [7] ".__C__DiscreteGeneratorProto" ".__C__DiscreteVertexProto" [9] ".__C__EdgeProto" ".__C__FactorEdgeProto" [11] ".__C__FactorVertexProto" ".__C__GeneratorProto" [13] ".__C__GraphLatticeProto" ".__C__LinearGeneratorProto" [15] ".__C__NodeProto" ".__C__OrdinalVertexProto" [17] ".__C__QuadraticGeneratorProto" ".__C__VertexEdgeProto" [19] ".__C__VertexProto" ".__M__addToPopups:dynamicGraph" [21] ".__M__ancestors:dynamicGraph" ".__M__ancestors<-:dynamicGraph" [23] ".__M__color:dynamicGraph" ".__M__color<-:dynamicGraph" [25] ".__M__Colors:dynamicGraph" ".__M__Colors<-:dynamicGraph" [27] ".__M__descendants:dynamicGraph" ".__M__descendants<-:dynamicGraph" [29] ".__M__draw:dynamicGraph" ".__M__edgeLabel:dynamicGraph" [31] ".__M__edgeLabel<-:dynamicGraph" ".__M__edgeWidth:dynamicGraph" [33] ".__M__edgeWidth<-:dynamicGraph" ".__M__index:dynamicGraph" [35] ".__M__index<-:dynamicGraph" ".__M__Indices:dynamicGraph" [37] ".__M__label:dynamicGraph" ".__M__label<-:dynamicGraph" [39] ".__M__labelOfEdge:dynamicGraph" ".__M__labelOfEdge<-:dynamicGraph" [41] ".__M__labelPosition:dynamicGraph" ".__M__labelPosition<-:dynamicGraph" [43] ".__M__LabelPositions:dynamicGraph" ".__M__LabelPositions<-:dynamicGraph" [45] ".__M__Labels:dynamicGraph" ".__M__Labels<-:dynamicGraph" [47] ".__M__name:dynamicGraph" ".__M__name<-:dynamicGraph" [49] ".__M__Names:dynamicGraph" ".__M__Names<-:dynamicGraph" [51] ".__M__NodeAncestors:dynamicGraph" ".__M__NodeAncestors<-:dynamicGraph" [53] ".__M__NodeDescendants:dynamicGraph" ".__M__NodeDescendants<-:dynamicGraph" [55] ".__M__nodeIndices:dynamicGraph" ".__M__NodeIndices:dynamicGraph" [57] ".__M__nodeIndices<-:dynamicGraph" ".__M__nodeIndicesOfEdge:dynamicGraph" [59] ".__M__nodeIndicesOfEdge<-:dynamicGraph" ".__M__NodeTypes:dynamicGraph" [61] ".__M__nodeTypesOfEdge:dynamicGraph" ".__M__oriented:dynamicGraph" [63] ".__M__Oriented:dynamicGraph" ".__M__oriented<-:dynamicGraph" [65] ".__M__Oriented<-:dynamicGraph" ".__M__position:dynamicGraph" [67] ".__M__position<-:dynamicGraph" ".__M__Positions:dynamicGraph" [69] ".__M__Positions<-:dynamicGraph" ".__M__Strata:dynamicGraph" [71] ".__M__Strata<-:dynamicGraph" ".__M__stratum:dynamicGraph" [73] ".__M__stratum<-:dynamicGraph" ".__M__visible:dynamicGraph" [75] ".__M__Visible:dynamicGraph" ".__M__visible<-:dynamicGraph" [77] ".__M__Visible<-:dynamicGraph" ".__M__width:dynamicGraph" [79] ".__M__width<-:dynamicGraph" ".__M__widthOfEdge:dynamicGraph" [81] ".__M__widthOfEdge<-:dynamicGraph" ".__M__Widths:dynamicGraph" [83] ".__M__Widths<-:dynamicGraph" ".onLoad.dynamicGraph" [85] ".onLoad.dynamicGraphInterface" "addToPopups" [87] "ancestors" "ancestors<-" [89] "blockTreeToList" "color" [91] "color<-" "Colors" [93] "Colors<-" "descendants" [95] "descendants<-" "draw" [97] "DynamicGraph" "dynamicGraphMain" [99] "edgeLabel" "edgeLabel<-" [101] "edgeWidth" "edgeWidth<-" [103] "index" "index<-" [105] "Indices" "label" [107] "label<-" "labelOfEdge" [109] "labelOfEdge<-" "labelPosition" [111] "labelPosition<-" "LabelPositions" [113] "LabelPositions<-" "Labels" [115] "Labels<-" "modalDialog" [117] "name" "name<-" [119] "Names" "Names<-" [121] "nameToVertexIndex" "newBlock" [123] "newBlockEdge" "newDefaultModelObject" [125] "newDefaultTestObject" "newFactor" [127] "newFactorEdge" "newVertex" [129] "newVertexEdge" "NodeAncestors" [131] "NodeAncestors<-" "NodeDescendants" [133] "NodeDescendants<-" "nodeIndices" [135] "NodeIndices" "nodeIndices<-" [137] "nodeIndicesOfEdge" "nodeIndicesOfEdge<-" [139] "NodeTypes" "nodeTypesOfEdge" [141] "oriented" "Oriented" [143] "oriented<-" "Oriented<-" [145] "position" "position<-" [147] "Positions" "Positions<-" [149] "returnBlockEdgeList" "returnEdgeList" [151] "returnFactorEdgeList" "returnFactorVerticesAndEdges" [153] "returnVertexList" "setBlocks" [155] "setTreeBlocks" "Strata" [157] "Strata<-" "stratum" [159] "stratum<-" "validFactorClasses" [161] "validVertexClasses" "visible" [163] "Visible" "visible<-" [165] "Visible<-" "width" [167] "width<-" "widthOfEdge" [169] "widthOfEdge<-" "Widths" [171] "Widths<-"> ls()[1] "a"> b <- DynamicGraph(1:5) >-----Oprindelig meddelelse----- Fra: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] Sendt: 16. marts 2004 12:37 Til: Jens Henrik Badsberg Cc: r-help at stat.math.ethz.ch Emne: Re: [R] Documentation on how to put classes and methods in packageswith namespace? See `Writing R Extensions' in 1.9.0 alpha and the stats4 package there as an example. At this point you probably only want to check a package against 1.9.0 alpha, anyway. On Tue, 16 Mar 2004, Jens Henrik Badsberg wrote:> > Documentation on how to put classes and methods in packages with namespace? > > How should I define my classes and methods in "dynamicGraph"??? > > (That is - Can some one point me to the documentation on > how to put classes and methods in packages with a namespace? )[...] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595