Re: [Rd] package.skeleton.S4

2008-03-31 Thread John Chambers
Christophe, Thanks for your work; unfortunately, at the same time you were developing your version, the original function was being extended in the same direction. The version of package.skeleton() to be included in the 2.7.0 release of R will deal with S4 classes and methods. When you have

Re: [Rd] revision 44805 breaks promptMethods()

2008-03-24 Thread John Chambers
I think, as of just 2 revisions later (44863) anyway, that problem has been fixed. Sitting in the methods/R directory: grep -nH -e isGenericFunction *.R Grep finished with no matches found at Mon Mar 24 16:55:39 Try updating see if all is well. (r-devel is a moving target, particularly a

Re: [Rd] NAMESPACEs and S4 classes

2008-02-18 Thread John Chambers
Let's start from a simpler description, because the use of sealed adds some confusion. Here's a basic version. I have two packages, P2 and P3, with different definitions of myClass. Classes with the same name on two packages are supposed to work, at least for generating objects. There is

Re: [Rd] trace() problems (PR#10498)

2007-12-06 Thread John Chambers
The problem is at least as old as 2.5.1. Looks like a line disappeared from trace(), something like: on.exit(tracingState(tState)) As a result, if an error occurs in the call to trace(), the tracing state is left FALSE. The workaround is to turn it on explicitly: tracingState(TRUE)

Re: [Rd] slots of type double

2007-11-13 Thread John Chambers
What's the proposal here? To eliminate double as a class? No objection from this corner. As I remember, it was put in early in the implementation of methods, when I was confused about what R intended in this area (well, I'm not totally unconfused even now). If this is the proposal, we could

Re: [Rd] R 2.6.0 S4 data breakage, R _data_class(), class-, etc.

2007-10-07 Thread John Chambers
Most of your problems seem related to assigning an S4 class to an arbitrary object--a really bad idea, since it can produce invalid objects. Objects from S4 classes are created by calling the function new(), and in principal _only_ by calling that function. Objects from one class are coerced

Re: [Rd] R2.6 bug in arithmetics of S4 classes inherited from 'array', or intended behavior?

2007-07-28 Thread John Chambers
Yes, this is the intended behavior. Nothing to do with implicit generics, but with some ongoing changes to make class structure and related classes such as array give trustworthy results consistent with the S language idea of vector structures. There's a short note in NEWS about the changes,

Re: [Rd] S4 and Namespaces problems {was error message from lmer}

2007-07-19 Thread John Chambers
Generic functions include a package slot. The concept is that only one definition of the generic _for a particular package_ should exist. For various reasons, there may be copies of that generic in multiple places (from the way namespaces work, e.g.) but the model is that they are really the

Re: [Rd] Math group generics for S4, and a bug

2007-06-26 Thread John Chambers
Martin Maechler wrote: MM == Martin Maechler [EMAIL PROTECTED] on Sat, 23 Jun 2007 00:36:43 +0200 writes: {on R-help} [.] [.] Duncan Murdoch DM You might have better luck with DM log1p(tasa) MM

Re: [Rd] Missing args with a default value in S4 methods

2007-06-17 Thread John Chambers
special mechanism. I'm not against cleaning up the semantics but there would need to be a clear proposal that wouldn't impose a serious penalty (for example, always rematching the arguments even when the formal arguments are identical could be such a penalty). Herve Pages wrote: John Chambers

Re: [Rd] S3 vs S4 classes

2007-02-17 Thread John Chambers
Rossi, Peter E. wrote: I have developed a package, bayesm, which uses existing classes of objects. I would like to add a new class corresponding to objects from this package. I have been reading about classes and all sources tell me that I should use so-called new or S4 classes.

Re: [Rd] How to put my S4 class into data.frame

2006-11-04 Thread John Chambers
Designing a better data frame is something many people have likely thought about; I certainly have. But data frames are so widely used and so central to models and other software that a major change needs to be done by the user community, or at least with maximum feedback, IMO. Also, my prior

Re: [Rd] Formal methods are not loaded from NAMESPACE in reloadedworkspace image

2006-11-04 Thread John Chambers
object=ur.kpss object=ur.pp object=ur.sp object=ur.za and summary(lc.df) then works as expected. So the workaround, other than inserting all the import(methods), etc. you can think of, seems to be to save/load explicitly. Seth Falcon wrote: John Chambers [EMAIL PROTECTED] writes

Re: [Rd] Formal methods are not loaded from NAMESPACE in reloadedworkspace image

2006-11-03 Thread John Chambers
I haven't had a chance to verify these exact examples, but the likely explanation is that loading the workspace does not cache the saved methods. Assuming this is indeed what's happening, the workaround is to cache them manually by the call: cacheMetaData(.GlobalEnv) (after attaching the

Re: [Rd] WG: Formal methods are not loaded from NAMESPACE inreloadedworkspace image

2006-11-03 Thread John Chambers
Well, at the moment I'm a little confused too. It's not at all as simple as my previous mail suggested. Here's what I know, and unfortunately I won't have too much time to look further for a while. Starting from a clean folder (no saved workspace): library(urca) showMethods(summary)

Re: [Rd] Formal methods are not loaded from NAMESPACE in reloadedworkspace image

2006-11-03 Thread John Chambers
. you can think of, seems to be to save/load explicitly. Seth Falcon wrote: John Chambers [EMAIL PROTECTED] writes: I haven't had a chance to verify these exact examples, but the likely explanation is that loading the workspace does not cache the saved methods. Assuming this is indeed

Re: [Rd] Pb with .findInheritedMethods

2006-10-29 Thread John Chambers
Seth Falcon wrote: John Chambers [EMAIL PROTECTED] writes: As I mentioned, this relates to writing methods for initialize(). Imagine someone else extends the class Ab, for which you wrote a method. If they add slots to their class and you do not pass down ... to callNextMethod

Re: [Rd] Pb with .findInheritedMethods

2006-10-28 Thread John Chambers
Herve Pages wrote: More generally I don't see what's wrong with not passing to callNextMethod all the arguments coming from the call to new: setClass(A, representation(toto=integer)) setMethod(initialize, A, function(.Object, toto0) [EMAIL PROTECTED] - as.integer(toto0);

Re: [Rd] Pb with .findInheritedMethods

2006-10-27 Thread John Chambers
A problem with callNextMethod, which is caching an inherited method as if it was not inherited, causing confusion on the next search. Should be fairly easy to fix, but may be a while before I get time to do so. By the way, I hope your simplified example does not reflect what happens in the

Re: [Rd] S4 pb in R 2.5.0

2006-10-27 Thread John Chambers
Thanks for the typo, it might have taken a while to find this one otherwise! In 2.5.0 and 2.4patched, the subclass information attempts to be complete. That subclass information needs to be removed from all superclasses when the class is redefined, and currently isn't. The particular

Re: [Rd] default arguments in generics and methods

2006-10-21 Thread John Chambers
You're conflating 3 different things here: how methods are selected, how R treats missing arguments, and how the standardGeneric() call is implemented. Maybe more relevant, if this question is motivated by a practical need, you may want to rethink what the generic function does. Nonstandard

Re: [Rd] understanding virtual classes and extensions thereof

2006-10-21 Thread John Chambers
IMO, the recommended version is: setClass(kid2, contains = c(mom, VIRTUAL)) because it's the clearest, using the representation argument only for defining slots. Better yet, if your virtual classes don't have any slots defined, use setClassUnion() for mom, with the other classes members of

Re: [Rd] Caching bug with showMethods?

2006-10-18 Thread John Chambers
No, not a bug. Inherited methods are never cached until they are needed, for rather obvious efficiency reasons. See ?showMethods, under argument inherited= If what you were trying to do was find out what method would be called for class B without calling it, use selectMethod(). Seth Falcon

Re: [Rd] Caching bug with showMethods?

2006-10-18 Thread John Chambers
, but excluding ANY from the superclasses used. That's quite a different (and longer) calculation than showMethods() does, but could indeed be useful. Seth Falcon wrote: John Chambers [EMAIL PROTECTED] writes: No, not a bug. Inherited methods are never cached until they are needed

Re: [Rd] getMethods() not finding all methods

2006-10-13 Thread John Chambers
Steven McKinney wrote: Hi Seth, Thanks for the info - actually one of the things I like about getMethods is seeing the function internals Yes, that's why showMethods() has the option includeDefs=TRUE to include the definitions. There are other options to look at multiple functions or

Re: [Rd] getMethods() not finding all methods

2006-10-13 Thread John Chambers
Seth Falcon wrote: John Chambers [EMAIL PROTECTED] writes: Yes, that's why showMethods() has the option includeDefs=TRUE to include the definitions. There are other options to look at multiple functions or specific classes. Look at ?showMethods A feature request: it would

Re: [Rd] dispatching on group generics with more than one formal

2006-10-11 Thread John Chambers
Yes, a bug. The problem is that all generics start off with only 1 active argument in the signature (for efficiency). As soon as a method is specified with 1 args in the signature, the number of active arguments is supposed to be incremented accordingly. But specifying the method for the

Re: [Rd] class unions?

2006-10-06 Thread John Chambers
The problem is a combination of a class union definition that includes a basic type as a member, and is not in a package. Class numeric is sealed, so at present setClassUnion() doesn't cache the new superclass in the definition of numeric. In 2.4.0 that happens when a package is attached

Re: [Rd] Default argument value for [

2006-10-06 Thread John Chambers
Should now be fixed in r-devel and 2.4 patched. Iago Mosqueira wrote: El mié, 04-10-2006 a las 09:52 -0400, John Chambers escribió: I think the problem in your case comes from the mechanism used to handle non-standard argument lists; notice that you have added 3 new arguments

Re: [Rd] Default argument value for [

2006-10-04 Thread John Chambers
I think the problem in your case comes from the mechanism used to handle non-standard argument lists; notice that you have added 3 new arguments. If you look at the body of the resulting method you will see that the mechanism used to handle this (defining a function .local) fails to copy the

Re: [Rd] Help for methods

2006-10-02 Thread John Chambers
The convention for documenting S4 methods provides a general way to get the documentation for a method, given the name of the function and the name(s) of the classes in the signature: method?FUN,CLASS1,CLASS2,... where FUN is the name of the function and CLASS1, etc. are the names of the

Re: [Rd] S4 accessors

2006-09-28 Thread John Chambers
. On Wed, Sep 27, 2006 at 02:08:34PM -0400, John Chambers wrote: Seth Falcon wrote: John Chambers [EMAIL PROTECTED] writes: There is a point that needs to be remembered in discussions of accessor functions (and more generally). We're working with a class/method mechanism

Re: [Rd] S4 accessors

2006-09-27 Thread John Chambers
There is a point that needs to be remembered in discussions of accessor functions (and more generally). We're working with a class/method mechanism in a _functional_ language. Simple analogies made from class-based languages such as Java are not always good guides. In the example below, a

Re: [Rd] S4 accessors

2006-09-27 Thread John Chambers
Seth Falcon wrote: John Chambers [EMAIL PROTECTED] writes: There is a point that needs to be remembered in discussions of accessor functions (and more generally). We're working with a class/method mechanism in a _functional_ language. Simple analogies made from class-based languages

Re: [Rd] generics for primitive functions

2006-09-23 Thread John Chambers
Probably a bug, but not at all the one you imply. You have found a way to subvert a guarantee in R that methods for primitives can never be redefined for basic data types. As you no doubt found, but didn't show us, so long as you say sqrt(4) the result is correct. (Your Works should really

Re: [Rd] Help for methods

2006-09-19 Thread John Chambers
It's not likely that S3 methods will ever go away, at least in the sense that all the code using them would be rewritten. What we can work towards is to make more of the automated tools work for S3 methods as well as S4. This will usually involve package owners generating some information,

Re: [Rd] attributes of S4 objects

2006-09-15 Thread John Chambers
Parlamis Franklin wrote: I am having a bit of a struggle deciding when to use attributes with S4 objects. Clearly the 'class' attribute will always be present. But it is not clear to me whether the architects of the methods package intend that other attributes, such as 'names', will

Re: [Rd] setMethod() woes

2006-09-15 Thread John Chambers
The document on developer.r-project.org/howMethodsWork.pdf explains why the two methods are equally close. Please (re)read it. If you know what methods you want for mixing the two objects, you must either say so or arrange the classes in an inheritance that includes both classes. Robin

Re: [Rd] S4 Method dispatch in recent 2.4.0alpha

2006-09-13 Thread John Chambers
1.11.2 1.3.1 Biobase 1.11.34 === John Chambers wrote: Good example. The basic problem is in the NAMESPACE file: importFrom(graphics, plot) But the version of plot() in the graphics package is not a generic

Re: [Rd] setMethod(c) [was: setMethod(Summary)]

2006-09-07 Thread John Chambers
() is not appropriate. Robin Or is there some workaround that would enable me to do this? well, yes: As John Chambers has tried to say, you have to teach your users to use cWithPairs() or c2() or myC() or c.() or any reasonable name, but not c(). Martin [[alternative HTML

Re: [Rd] Matrix package in R-2.4.0alpha

2006-09-07 Thread John Chambers
Sounds like you don't have a version Matrix installed from source for 2.4.0. As mentioned earlier on this list, the caching mechanism has changed for methods, and all packages need to be installed from source to get the correct objects. Works fine for me with an installation of Matrix from

Re: [Rd] setMethod(c) [was: setMethod(Summary)]

2006-09-06 Thread John Chambers
to c() is a brob? On 5 Sep 2006, at 16:47, John Chambers wrote: (Before someone else can embarrass me with the reference) There is a variant on the c() example discussed in Programming with Data, page 351, for the function max(). John John Chambers wrote: It's all very well

Re: [Rd] setMethod(c) [was: setMethod(Summary)]

2006-09-05 Thread John Chambers
It's all very well to go on about efficiency, but the purpose of statistical computing is insight into data, not saving CPU cycles (to paraphrase Dick Hamming). S3 methods do some things fine; other tasks need more flexibility. One should ask what's important in a particular application and

Re: [Rd] setMethod(c) [was: setMethod(Summary)]

2006-09-05 Thread John Chambers
(Before someone else can embarrass me with the reference) There is a variant on the c() example discussed in Programming with Data, page 351, for the function max(). John John Chambers wrote: It's all very well to go on about efficiency, but the purpose of statistical computing is insight

[Rd] Internal flag for S4 objects

2006-09-03 Thread John Chambers
A recent revision (svn version 39077) has introduced an internal flag (a bit in the C structure) that is turned on by the code that generates objects from an S4 class. There are corresponding tests for an S4 object, isS4() in R and IS_S4_OBJECT() in C. These are fast and reliable, and should

Re: [Rd] S4 changes - sp fails

2006-09-01 Thread John Chambers
General comments. A number of packages will likely be showing weird warnings on attach() about packages being out of date. Likely caused by a confusion when two packages define the same generic. The bug is being worked on, but there are some issues of package design that will need

[Rd] S4 Methods dispatch

2006-08-30 Thread John Chambers
A revision of r-devel 2.4.0 is being committed today with changes to method and class management. The changes are internal but extensive. All packages that use S4 methods and classes need to be reinstalled from source to use the new version. The main effects are to speed up method caching

Re: [Rd] S4 Methods dispatch

2006-08-30 Thread John Chambers
John Chambers wrote: A revision of r-devel 2.4.0 is being committed today with changes to method and class management. The changes are internal but extensive. All packages that use S4 methods and classes need to be reinstalled from source to use the new version. A footnote

Re: [Rd] S4 Methods dispatch

2006-08-30 Thread John Chambers
Henrik On 8/30/06, John Chambers [EMAIL PROTECTED] wrote: A revision of r-devel 2.4.0 is being committed today with changes to method and class management. The changes are internal but extensive. All packages that use S4 methods and classes need to be reinstalled from source to use the new

Re: [Rd] + for character method...

2006-08-26 Thread John Chambers
Well, two comments, in two non-compatible directions. 1. I have to say that I find the idea of using + to paste character strings together aesthetically ugly. IMO, one thing that makes functional object-based languages attractive is that the generic function retains a consistent _function_,

Re: [Rd] [R] Successive subsets from a vector?

2006-08-23 Thread John Chambers
hadley wickham wrote: Providing the ability to write assignment functions that don't duplicate is a more urgent problem. You mean, for end-users? It can be done via primitives. Isn't this sort of a run-time optimisation? I thought R generally followed the functional

Re: [Rd] S4 'object is not subsettable' in prototype

2006-08-21 Thread John Chambers
but for which length(x), x[], x[1] and other computations go through with no complaints. And all without the benefit of any methods, S3 or S4. Just do x - NULL Seth Falcon wrote: John Chambers [EMAIL PROTECTED] writes: When I was introducing the special type for S4 objects, my first

Re: [Rd] S4 'object is not subsettable' in prototype

2006-08-20 Thread John Chambers
When I was introducing the special type for S4 objects, my first inclination was to have length(x) for those objects be either NA or an error, along the lines that intuitively length(x) means the number of elements in the vector-style object x. However, that change quickly was demonstrated to

[Rd] S4 object type (Was: S4 object type available for testing)

2006-08-08 Thread John Chambers
source. Also, a note about future changes: There will likely be two more changes to S4 code in the next few weeks: an internal bit to mark S4 objects for testing, and a new version of method dispatch designed to fix some logical flaws and to be more efficient. John Chambers wrote: The default

Re: [Rd] validObject() - slow down ?! [was package:Matrix handling ...]

2006-07-10 Thread John Chambers
If you want to avoid checking your objects for validity, create them as default objects and then set the slots. validObject is only called if new() gets optional arguments. and it's not called when a slot is assigned (because in some cases an invalid intermediate object will exist, between two

Re: [Rd] attributes of environments

2006-07-07 Thread John Chambers
Umm, maybe we should step back a bit here. There are two points being made, both of which I think are reasonable, but they just don't happen to work together. 1. Environments are special objects in R. In fact they are the essential way directly in R to implement reference semantics. Every

Re: [Rd] confused by inheritance...

2006-05-23 Thread John Chambers
This may be related to the problems with greedy search for inherited methods discussed previously on this list (or may not, it's a bit different). In any case, the likely fix will be a substantial cleaning up of generic functions hoped for in the next release. Meanwhile, Keep it simple is the

Re: [Rd] S4 initialize methods, unexpected recursive callNextMethod

2006-05-13 Thread John Chambers
The bug should now be fixed. The actual change is very small, but it enforces a semantic definition that may be relevant, so we should discuss it. The question is: what method does callNextMethod() refer to? The definition now enforced is: the next method is the method found for the

Re: [Rd] S4 initialize methods, unexpected recursive callNextMethod

2006-05-11 Thread John Chambers
It's a bug resulting from the combination of: 1. multiple recursive levels of callNextMethod() 2. nonstandard arguments in the method definition; that is, (.Object, x) vs .Object, ...) for the generic. Specifically, the callNextMethod code tries to build up a list of excluded classes, but in

Re: [Rd] [R] S4 method dispatch matrixOrArray (fwd)

2006-04-13 Thread John Chambers
What a delicious example! (I'm taking the liberty of sharing it with r-devel, since it raises some good issues.) You have two questions, presumably: 1 - how could the order of the setMethod calls make a difference in the results? 2 - what's causing the infinite loop how could it be avoided,

Re: [Rd] yet another problem with S4 dispatch (with setClassUnion)

2006-04-12 Thread John Chambers
As I think Seth told you before, if you want to control the order of inheritance at the same level, you need to use the intended order in the contains= argument to setClass. In your example (retaining the class union, although it's not required, the superclass could just be an ordinary

Re: [Rd] [R] type converters not being saved to workspace

2006-04-11 Thread John Chambers
(diverted to r-devel) The problem seems to be rather that loading of the saved image takes place _after_ the packages are attached. So nothing that the methods package does in its initialization will see the relevant type converters or other methods objects. More generally, loading into

Re: [Rd] setIs and method dispatch in S4 classes

2006-04-10 Thread John Chambers
From your description of the application, it sounds like you would be better off just forcing + to behave as you want. Using inheritance is a much more powerful mechanism can introduce results you don't want, as it seems to have in this case. An important point about using inheritance is

Re: [Rd] setIs and method dispatch in S4 classes

2006-04-10 Thread John Chambers
Seth Falcon wrote: Hi John, I found your comments helpful, even though this isn't _my_ question. But now I have one of my own :-) John Chambers [EMAIL PROTECTED] writes: Of course, I could also declare explicitly + methods for signatures c(Exp, Exp), c(Exp, Gammad), and c(Gammad, Exp

Re: [Rd] write.table and segment fault?

2006-03-29 Thread John Chambers
David had reported this to me privately earlier today. I'm fairly sure the problem is caused by an invalid factor variable, with numeric rather than integer data. At the moment I'm checking a patch to scan.c that checks this to avoid a segfault. If that's not the problem I'll report back to

[Rd] changes in r-devel for S3/S4 objects

2006-02-20 Thread John Chambers
Two recent changes have been committed to r-devel, related to discussions on this list earlier: 1. setOldClass() has an argument prototype= to specify the default object for the class. If provided, the S3 class can be a slot in an S4 class, with a valid default object. (It's still not going

Re: [Rd] match gets confused by S4 objects

2006-02-07 Thread John Chambers
In fact there is a heuristic test that is cheap and reasonably reliable. The class attribute generated for S4 objects itself has an attribute, package. A C-level test for the existence of that attribute is cheap enough, I would think, that most anti-S4 users wouldn't notice it in match(),

Re: [Rd] S4 default initialization: unwanted NULL

2006-01-03 Thread John Chambers
Seth Falcon wrote: On 3 Jan 2006, [EMAIL PROTECTED] wrote: It's legal to have virtual classes as slots, but yes, the slot is NULL in the prototype for the new class, unless the user specifies a value. In your case, providing a non-null prototype for the data.frame slot might be the desired

Re: [Rd] Wish list

2006-01-02 Thread John Chambers
I very much share Duncan's concern that research in statistical software should move ahead, and contribute to some of the exciting new uses of data we see. R is the most striking success in statistical software over the last decade, in terms of the variety and quantity of statistical

Re: [Rd] Registering S3 class from external package

2005-08-18 Thread John Chambers
Your description is a bit too vague to be sure, but it sounds as if you're trying to do something that breaks the basic namespace idea. Paul Roebuck wrote: The package I'm working on can extract data from external packages but would otherwise have no dependency on them. However, I desire to

Re: [Rd] S4 generating function

2005-08-05 Thread John Chambers
First, anyone planning to debug methods should consider the general form of the trace() function with signature= to say what method to trace, and some suitable interactive function such as browser or recover to examine the computations. See ?trace In this example, something like:

Re: [Rd] S4 setClass with prototypes issues (PR#8053)

2005-08-05 Thread John Chambers
Well, let's say R is currently picky when only a prototype is supplied. The following is either a workaround or a revised, fussier requirement for the example mentioned, depending on your interpretation. R setClass(sequence, representation(.Data=numeric), prototype=numeric(3)) [1] sequence R

Re: [Rd] S4 generating function

2005-08-05 Thread John Chambers
for the initialize() method. Leave them as .Object, ... and extract the id= component. dotArgs - list(...) id - dotArgs$id Or, wait for a fix. There should at least be one in r-devel sometime fairly soon. Paul Roebuck wrote: On Fri, 5 Aug 2005, John Chambers wrote: Paul Roebuck wrote: Can

Re: [Rd] S4 Dispatching

2005-07-22 Thread John Chambers
Paul Roebuck wrote: On Wed, 20 Jul 2005, John Chambers wrote: Paul Roebuck wrote: Is it possible for S4 to (continue) dispatch to a class created during dispatching? The code below doesn't work; is this not possible or have I ommitted something? doesn't work? This is not helpful. Please

<    1   2   3