[EMAIL PROTECTED] wrote:
When I define an S4 class ("B" in the example below) that directly extends
another ("A" in the example below) , which in turn directly extends another
("character" in the example below), I find that the slot does not have the
class I specified in setClass(), it has the unde
Byron Ellis wrote:
Some quick questions about S4 methods.
Does the typing of S4 methods mean that lazy evaluation is no longer
possible? It seems that you would need to evaluate the arguments to
determine their type at dispatch.
Yes, it would be a neat trick to know the class of an actual argumen
Witold Eryk Wolski wrote:
Hi,
While checking the package I am getting all the time the following
complain about the function:
Undocumented S4 methods:
generic coerce and siglist matrix,Massvector
I have not defined the function nowhere in the R files.
My gues is that this has something to do wi
Witold Eryk Wolski wrote:
Dear developers.
Have spend just 1 h searching for a bug in a new version of a new
version of a package.
I was getting a segfault all the time. "Funny" thing - there was no
error neither in the S nor in the C code.
To solve the problem I had to delete the .Rdata file!
McGehee, Robert wrote:
Thank you for your replies. I greatly appreciate the wealth of
documentation on this subject and the time spent by the John Chambers
and the R Core Team making object-orient programming in R a reality. I
hope to be able to give code (not just bug reports) back to the R
if (is.primitive(baseDef)) {
value <- genericForPrimitive(f)
and it seems John Chambers has defined an S4 generic for as.character
with one arg, "x". Had he not done so it would have been (x, ...). My
guess is that this is because in S the arg list is (x) and he ov
Too bad you didn't stick to your earlier intention:
> I'll leave it up to the developers to designate this as a bug or not,
> but I would certainly prefer that new() and show() never reports errors
> when an empty object is passed as an argument (of any class).
I agree, assuming what you mean by "e
Your example and your subject heading are two different things. If you
meant the subject heading, that in fact works.
R> setClass("a1", representation(x="array"))
[1] "a1"
R> new("a1", x=matrix(1:12,3,4))
An object of class "a1"
Slot "x":
[,1] [,2] [,3] [,4]
[1,]147 10
[2,]
John Fox wrote:
Dear r-devel list members,
I'm moving this question to r-devel because it seems thornier than I
originally thought.
Yes, it's certainly not for r-help.
I've already mentioned (on r-help) that the approach that John Chambers
suggested (below) fails for objects of
Jeffrey J. Hallman wrote:
OK, I looked at the documentation and you're right about that. However,
I'm curious about why the first argument to UseMethod is ever necessary.
Is there ever a good reason for it to be something other than the name
of the calling function? (Wouldn't that lead to confusi
[EMAIL PROTECTED] wrote:
>
> Hello,
>
> I have a question concerning "setClassUnion".
It's not really about setClassUnion, but a bug in handling slots in
prototypes whose class extends a locally defined class (a class union is
an example, but others would fail the same way).
> I'm working with
The source of the problem is that, because "list" is a basic class,
there is a pre-defined method for as(x, "list") (roughly, use
as.list(x)). (Technically, this is found as a method for the coerce()
function.)
Normally, setIs() doesn't explicitly set the method for coerce(),
delaying that until
Eric Lecoutre wrote:
>
> Hi,
>
> For your lm problem, you could begin to create a virtual class that accepts
> either NULL or a lm object:
>
> > setClassUnion("mylm", c("NULL","lm"))
> > setClass("foo", representation(x="numeric", y="mylm"))
> > new("foo",x=1,y=NULL)
>
> Then, you have to ch
tClass("lm")
> Error in setClass("lm") : "lm" has a sealed class definition and cannot
> be redefined
>
> I understand the errror message but I can't see the difference between
> class Krig and lm which are both S3 classes. (of course except
Wolski wrote:
>
> Hi!
> Consider this code.
>
> setClass("Ctest"
> ,representation(
> test="character"
> ,bla="character"
> ,mod="lm"
> )
> )
>
> new("Ctest",test="bla") #This produces an error.
>
It works better if you give setClass the right arguments.
In your second call, you omitted the representation= argument, so you
need to name the prototype argument:
setClass("AtomList"
,contains="List"
,prototype =
prototype(content="Atom")## wou
I did say the workaround was only a candidate!
Try changing the first line to:
setClass("listNamed",
representation(names = "character"), contains = "list")
(because the automatically generated as() methods for further derived
classes, e.g. your Mlist, will not copy the names unless th
cat("An object of class ", class(object), "\n", sep="")
show(as(object, "list"))
})
-----
(By the way, the workaround depends on the bug fix to setAs committed
recently to r-devel, so if
Please re-read the previous mail to see answers to your questions, as
noted below.
Wolski wrote:
>
> Hi!
>
> Some follow up questions concerning the class definition of list.
>
> On 9/7/2004 at 11:47 AM John Chambers wrote:
> >>>
> >>>as(object
51-07-0
>
> > class(tt)
> [1] "myclass"
> attr(,"package")
> [1] ".GlobalEnv"
> > as(tt,"vector")
> [1] 1 2 3 4 5 6
> > summary(dd[,1])
>Min. 1st Qu. MedianMean 3rd Qu.Max.
>1.001.251.50
list"
Extends: "vector"
The main candidates for wrapper classes are "matrix" and "array", since
these do not have a fixed set of attributes (they may or may not have
"dimnames"). Class "ts" is already a formal class.
John Chambers
Wolski w
It's not possible to tell what you're expecting or actually seeing from
this mail. We need to see your code and the results, not your
interpretation of how as() is implemented.
Meanwhile, here's how a simple class that extends "matrix" works in
2.0.0
With the code:
setClass("mat1", representa
Some more fixes have been committed to r-devel, again with the aim of
making S4 classes, including non-exported classes, work with
namespaces. (This is inevitably an iterative process of finding
examples where only the class name, without the relevant
package/environment, is passed down.)
John
--
One of the changes some packages are noticing from the recent
modifications to methods is warnings of "undefined classes" during
installation when the package extends S3 classes or uses them as slots
UNLESSS they have been declared in a setOldClass() call. The green book
"strongly recommends" dec
x27;t really mean to insert an undefined class as a slot --
that a warning (not an errorr) seems desirable. (S3 classes are fine as
slots, but unless setOldClass is used they can't be verified.)
John
>
> Brian
>
> On Tue, 24 Aug 2004, John Chambers wrote:
>
> > An e
An extensive set of changes to the methods package has been committed
today to allow non-exported classes from packages with namespaces (and
some related fixes in dealing with generic functions from namespaces as
well).
The namespace mechanism requires packages to export any class
definitions that
[EMAIL PROTECTED] wrote:
>
> # Your mailer is set to "none" (default on Windows),
> # hence we cannot send the bug report directly from R.
> # Please copy the bug report (after finishing it) to
> # your favorite email program and send it to
> #
> # [EMAIL PROTECTED]
> #
> ###
luded
> in the documentation but don't work. See example code below.
>
> Moreover, what about 'genericForPrimitive' which is used
> in 'getGeneric'. It seems that this method is not included in
> the R Version 1.9.1 (also 1.9.0). See the example code o
Peter Dalgaard wrote:
>
>
<..snip>
> Checking... Yep, the logic in R_sysfunction() is to give the function
> of frame #n:
>
> if (n > 0)
> n = framedepth(cptr) - n;
> else
> n = - n;
> if (n < 0 )
> errorcall(R_GlobalContext->call, "illegal frame number");
>
dealing with
existing objects (e.g., DATAPTR() pointers); in particular, so the heavy
C code uses only pointers to data, not R objects.
And hopefully real compiling will eventually relieve us of some of the
need.
John
Luke Tierney wrote:
>
> On 27 Apr 2004, Douglas Bates wrote:
>
>
I think you need to PROTECT the vector you're putting in the slot as
well as the overall object. At any rate, the problem goes away for me
with the revised version of dummy.c below. (Empirically, PROTECT'ing
the class definition didn't seem to be needed, but experience suggests
that too much prot
Tony Plate wrote:
>
> AFAIK identical() first introduced by Chambers in "Programming with
> data"? On p262 he writes:
>
> identical: The two objects must be exactly equal in all respects; if not
> identical returns FALSE
> all.equal: The two objects are expected to be identical up to small
> dif
John Chambers wrote:
>
> You're caught in a subtle "gotcha" with the combination of things you're
> doing. We're trying to sort out some of the interactions among
> namespace & methods at the moment, so there may be a nicer solution in
> the future
function object for
> function "print"
> Error in print("barprint method for bar") :
> S language method selection got an error when called from internal
> dispatch for function "print"
>
> end of R bit ---
>
John Chambers wrote:
.
>
>
>
> By the way, in the validity method you should not return a call to
> warning() as in your example. The validity method just returns a
> character string describing the problem.
Sorry, I misread the example, the "w
ize"
Then:
R> new("C2", x = 1, id = "OK")
An object of class "C2"
Slot "id":
[1] "OK"
Slot "x":
numeric(0)
R> try(new("C2", x = -1, id = "BAD!"))
Error in validObject(.Object) : Invalid
not really from
earlier versions. A function, fixPre1.8(names), will be added to the
patches for 1.8.1, to let users fix loaded objects, given the names of
the objects.
John Chambers
"Heywood, Giles" wrote:
>
> I am having difficulty using in 1.8.0 an object created under 1.7.
"A.J. Rossini" wrote:
>
> I'm seeing weird issues in methods initialization, i.e. loading
> marrayClasses loads Biobase, and when explicitly done, as in
>
>library(Biobase)
>library(marrayClasses)
>
> is fine, but when Biobase is loaded via a require statement in
> marrayClasses' .First.
In 1.8, the functional forms of "?" (?f(...) and method?f(...)) were not
finding the generic function & therefore not reporting method
documentation. Should be fixed in a version of r-patched committed
today.
--
John M. Chambers [EMAIL PROTECTED]
Bell Labs, Lucent Technologies
John Chambers wrote:
>
> [EMAIL PROTECTED] wrote:
> >
> > > setClass('foo')
> > [1] "foo"
> > > setMethod('is.logical', 'foo', function(x) TRUE)
> > [1] "is.logical"
> > > getGeneric('is
Saikat DebRoy wrote:
>
> On Monday, Oct 13, 2003, at 16:17 US/Eastern, John Chambers wrote:
>
> > As a heuristic, setting methods for language-related primitives is
> > dangerous (also a little strange?).
>
> Yes. But if it is allowed, someone will do it. It may actua
[EMAIL PROTECTED] wrote:
>
> > setClass('foo')
> [1] "foo"
> > setMethod('is.logical', 'foo', function(x) TRUE)
> [1] "is.logical"
> > getGeneric('is.integer')
> Error in options(x) : evaluation is nested too deeply: infinite
> recursion?
This is one of a number of potential problems when meth
David James wrote:
>
> Hello,
>
> It seems to me that Fernando may be right. The problem seems to be
> in R 1.8.0 when defining generics with explicit valueClass. E.g.,
>
> R-1.7.1:
>
>> setGeneric("foo", function(x) standardGeneric("foo"), valueClass="numeric")
>> setMethod("foo", "n
Prof Brian Ripley wrote:
>
> On Thu, 9 Oct 2003 [EMAIL PROTECTED] wrote:
>
> > The Complex group generic for S4 methods is not working:
> >
> > > setClass('foo', representation(z='complex'))
> > [1] "foo"
> > > setMethod('Complex', 'foo', function(z) callGeneric([EMAIL PROTECTED]))
> > [1] "Com
Thomas Stabla wrote:
>
> Hello,
>
> the last command (isGeneric) in following R-code (attached) produces
> different output, depending on wheter 1.8.0 alpha or 1.7.1 is used.
> Is that to be expected ?
This is a bug, but one that may be worth understanding.
In order to work properly with namesp
The problem seems to have been fixed with a change committed this
morning to the archive.
Martin Maechler wrote:
>
> > "Roger" == Roger D Peng <[EMAIL PROTECTED]>
> > on Sun, 28 Sep 2003 17:09:04 -0400 writes:
>
> Roger> I ran into a problem recently trying to update a
> Roge
Should now be consistent.
One problem was that the base namespace, unlike other namespaces, does
not have a .packageName object. I left this alone for now, and
special-cased the base namespace in getPackageName().
John
[EMAIL PROTECTED] wrote:
>
> I have mentioned this several times, and it is
Kurt Hornik wrote:
>
> >>>>> John Chambers writes:
>
> > Prof Brian Ripley wrote:
> >>
> >> On Tue, 16 Sep 2003, John Chambers wrote:
> >>
> >> > Jeff Gentry wrote:
> >> > >
> >> > > Hello ...
>
Prof Brian Ripley wrote:
>
> On Tue, 16 Sep 2003, John Chambers wrote:
>
> > Jeff Gentry wrote:
> > >
> > > Hello ...
> > >
> > > With a new checkout of R-devel (last update was 2003-09-11) we are having
> > > a problem (i
Jeff Gentry wrote:
>
> Hello ...
>
> With a new checkout of R-devel (last update was 2003-09-11) we are having
> a problem (it seems to be happening to all of us here on a few different
> machines) where during install/check/etc when the 'save image' happens (in
> packages using 'save image'):
>
Jeff Gentry wrote:
>
> I'm having difficulty building R-devel on Solaris 8 (current version),
> while trying to update from my previous version of R-devel (2003-09-02).
>
> When building I get this error:
> ---
> make[4]: Leaving directory
> `/misc/homes/madman/R-devel/src/library/met
Ross Ihaka wrote:
>
> John Chambers wrote:
> > The current version of the methods package now has a namespace. Packages
> > using S4 methods and classes can have NAMESPACE files. New directives
> > can be included in NAMESPACE files to import and export classes and
> &
An example sent by Ross Ihaka points out a non-obvious step needed to
export the results of setAs().
The as() mechanism can't use ordinary method dispatch because the second
argument is the name of a class, not an object from the class. So it
uses a "helper" function, coerce(), and sets methods f
We have a fix for this bug, which will be comitted, probably later
today. Be aware until then that some
methods for primitive functions may turn up missing if one package
requires() another. If you must use last night's version, a workaround
is to do
getAllMethods(f)
for the offending functions
The current version of the methods package now has a namespace. Packages
using S4 methods and classes can have NAMESPACE files. New directives
can be included in NAMESPACE files to import and export classes and
methods.
Namespaces allow cleaner definition of the API for packages, and are
needed f
[EMAIL PROTECTED] wrote:
>
> Full_Name: Colin A. Smith
> Version: 1.8.0
> OS: Mac OS X 10.2.6
> Submission from: (NULL) (216.102.90.18)
>
> Both Biobase and my package annaffy use S4 classes to define methods for "[".
> Both packages use the save image method of installation. (See annaffy 1.0.3 i
Yes, thanks. I have a corrected version checked out. It has some other
changes--as soon as I make a cleaned-up version with this fix only, I'll
commit it.
John
[EMAIL PROTECTED] wrote:
>
> Full_Name: Colin A. Smith
> Version: 1.8.0
> OS: Mac OS X 10.2.6
> Submission from: (NULL) (128.102.184.8
A revised version of the undoc() function in the tools package was
committed to r-devel today that attempts to implement the following
policy in checking for undocumented functions and methods in a package,
based on discussions recently on this list and in r-core:
If a package has methods for a fu
Roger Koenker wrote:
>
> I would like to add a class to the SparseM package. I have a class "matrix.csr"
> that describes a matrix in compressed sparse row format, now I would like a class
> matrix.diag.csr that describes such objects when they happen to be diagonal.
> The idea is that matrix.dia
The "undocumented methods" part of this one is easily fixed: undoc() was
calling getMethods() to get the methods defined. But this gets _all_
the visible methods of the generic, hence everyone was being charged for
everyone else's methods. Instead, undoc() should call the function
getMethodsMetaD
Seems that methods are being attributed a bit strangely in undoc().
Here's what I get with, I think, current r-devel and SparseM.
R> library(tools)
R> undoc("methods")
R> library(SparseM)
[1] "SparseM library loaded"
R> undoc("SparseM")
Undocumented code objects:
%x% as.matrix diag diag<- diff
> my code can handle and will substantially increase overall execution times.
> (The example in my previous post was not sufficient in itself to prove
> this, but more about that below.) There are other issues such as how to
> document S4 methods and how to pass RCMD check, but I wou
The general question is certainly worth discussing, but I'd be surprised
if your example is measuring what you think it is.
The numeric computations are almost the only thing NOT radically changed
between your two examples. In the first, you are applying a
"primitive" set of functions ("+", "$",
A number of changes were committed today.
Mainly:
1. It should now be possible to install packages using classes and
methods in a more straightforward way, and with or without saved images
(saved images are still recommended for efficiency). The idea is to be
able to write class & method defini
Torsten Hothorn wrote:
>
> Hi,
>
> how can one trace a nonstandardGenericFunction,
> especially "initialize"? An example:
>
> setClass("dummy", representation(a = "numeric"))
>
> setMethod("initialize", "dummy",
> function(.Object, a = 2) { ### I want to trace this function
>
Paul Gilbert wrote:
>
> John
>
> > But maintainers of software using S3 methods and classes
> > might want to consider conversions or partial conversions, when and if
> > they decide to revise the software.
>
> I'm curious about the logistics of a partial conversion. Initially I
> think I will a
Paul Gilbert wrote:
>
..
>
> There is no inheritance in the S3 sense when an object contains an
> object of another class. Am I missing something? Are you using this term
> loosely or is there necessarily inheritance in S4 when one object
> contains another object?
No, I'm n
ttributes go into slots (the slot
must have some specified class, but there are ways to allow some
variation in the actual type of data in the slot). S3 methods can
generally stay unchanged.
- classes with multiple strings can also be converted, again if they
have consistent attributes. In this ca
Some changes to the implementation of S4 classes in the methods package
will be committed to the r-devel version, probably later today. They
should be largely back-compatible (exception noted below) but they are
fairly extensive, so this is an advance notice.
The changes form the first of a two-s
"A.J. Rossini" wrote:
>
> Duncan Murdoch <[EMAIL PROTECTED]> writes:
>
> > I'd like to give a copy of an R package to someone using S-PLUS. It
> > doesn't just run as-is, it'll need changes. Has anyone written any
> > general guidelines on ways to port in that direction?
>
> I thought the othe
"Heywood, Giles" wrote:
>
> My question has two parts.
>
> The first is with regard to the frame or environment in which generic
> functions are defined in packages. It seems as though they are defined
> (i.e. exist as objects) in frame 1, even when defined in a package.
(Frame 1 is an S-Plus c
I think you didn't type what you meant to type (see below.)
Sourcing in your class descriptions with 1.7.1, I get what you expected.
> new("Annotation1")
An object of class "Annotation1"
Slot "x":
NULL
Slot "y":
NULL
Slot "catId":
[1] -1
Slot "isResolved":
[1] FALSE
Slot "resolve":
logical(0
(better late than never, hopefully--a few comments on this example)
Duncan Murdoch wrote:
>
> I'm trying to create a package for working on orientation data, i.e.
> data where the observations are 3D rotations.
>
> There are several different representations of orientations in common
> use: SO(
Duncan Murdoch wrote:
>
> On Fri, 13 Jun 2003 15:04:44 -0400, you wrote:
>
> >I think the problem is from not using a saved image. Using your tar
> >file, if I untar into orientlib/, I get the same error you report. But
> >after creating the install.R file:
>
> Thanks, that fixed it. Perhaps
Duncan Murdoch wrote:
>
> On Fri, 13 Jun 2003 13:18:23 -0400, you wrote:
>
> >It would be nice to be able to get a dump from the R CMD check
> >evaluation--maybe someone can suggest how.
>
> If I just cut all the preamble from the Rout file and paste it into
> the console, I get the same error.
Duncan Murdoch wrote:
>
> In the little orientation data package I'm working on, the very first
> example fails, even though the same code works when used in a regular
> session. In my experience, this usually indicates T or F has been
> used instead of TRUE or FALSE, but that's not the case this
.
John
>
> Regards,
>
> John Marsland
>
> PS this has been a very useful debate for those of us enthusiastically using
> S4 methods.
>
> > -Original Message-
> > From: Duncan Murdoch [mailto:[EMAIL PROTECTED]
> > Sent: 12 June 2003 18:54
>
ts of features! Many thanks.
The current code passes check-all here. Please let me know of any
problems. I'll be away the rest of today, but back tomorrow.
John
John Chambers wrote:
>
> Jeff Gentry wrote:
> >
> > On Wed, 4 Jun 2003, John Chambers wrote:
> >
Jeff Gentry wrote:
>
> On Wed, 4 Jun 2003, John Chambers wrote:
> > There was a bug leading to non-caching of methods, in the r-patched code
> > from a few days ago.
> > A branch update would have put the changes into R-devel also.
> > The problem has been pa
There was a bug leading to non-caching of methods, in the r-patched code
from a few days ago.
A branch update would have put the changes into R-devel also.
The problem has been partly fixed in the current code committed to
R-patched (and some further fixes are in the works).
(Sorry, this was dis
Luke Tierney wrote:
>
> On Mon, 2 Jun 2003, John Chambers wrote:
>
> > Laurent Gautier wrote:
> > >
> > > Hi,
> > >
> > > I have quite some trouble with the package methods.
> > > "Environments" in R are a convenient w
Laurent Gautier wrote:
>
> Hi,
>
> I have quite some trouble with the package methods.
> "Environments" in R are a convenient way to emulate
> pointers (and avoid copies of large objects, or of
> large collections of objects). So far, so good,
> but the package methods is becoming more (and more)
Sounds like a nice example. Just a quick comment on one question before
I have to run, will try to react more later.
John
Duncan Murdoch wrote:
>
> I'm trying to create a package for working on orientation data, i.e.
> data where the observations are 3D rotations.
>
> There are several differe
iuc.edu Roger Koenker Dept. of Economics UCL,
> email [EMAIL PROTECTED] Department of Economics Drayton House,
> vox:217-333-4558University of Illinois 30 Gordon St,
> fax:217-244-6678Champaign, IL 61820 London,WC1H 0AX
Hmm. Unfortunately (perhaps) it seems to work for me, with the current
R-patched and with the 0.27 version of SparseM from CRAN, I could
install and also run CMD check w/o error.
(This has the simpler version , setGeneric("as.matrix.csr"), which would
seem to me to be what you want.)
Could you t
I think this is a consequence of the extra context added to make methods
work right with R lexical scoping, namespaces, etc. Or a subtlety in
R's definition of missing()?
The problem is that somehow the default expression for argument `ncol'
makes that argument appear NOT to be missing. But an a
It's a (sort of trivial) bug in isSealedMethod, called by setMethod,
arising because "%*%" doesn't belong to group "Ops" (unlike "+", etc.)
so the check for sealed methods only looks as the first arg. See the
definition of function isSealedMethod for what's going on.
It's trivial to fix directly
Roger Koenker wrote:
>
> Suppose you have a class, say sex, for lack of a better example, and
> you are tempted, in defining the behavior of the call,
>
> is(x,"sex")
>
> to check whether certain basic features are satisfied, not to just trust the claim
> that x is specified to be of cla
Some fixes have been made to check a few errors better & to report
something like the correct error message in other cases.
- setMethod will now refuse to set a method for a primitive function for
a basic class ("[<-" for "matrix", for example). Previously the method
was set but never dispatched.
The original report was correct.
I fixed the problem & had sent a message to r-devel to that effect, but
we may have been having delays or other problems with our mailer.
Thanks again for the report, Paul.
John Chambers
Ross Ihaka wrote:
>
> Paul Gilbert wrote:
> > I think
1. UseMethod (via usemethod in objects.c) now uses the definition of
class() to dispatch, with the methods package attached (dataClass(x))
and without (attr(x, "class")).
Packages using a construction of the form
if(is.null(class(x))) class(x) <- data.class(x)
UseMethod("foo")
shou
I was a little optimistic that the modified version passed _all_ the
tests. When I installed the complete change, all the fullcheck tests
passed except two, demos and isas-tests.
There is a tiny difference in the output of the demos test, where the
previous demos.Rout had what looks like an unwan
he modification tomorrow am, New York
time.
John
Kurt Hornik wrote:
>
> >>>>> Prof Brian D Ripley writes:
>
> > On Fri, 17 Jan 2003, John Chambers wrote:
> >> There are two main known differences from having methods attached:
> >>
> >>
Prof Brian D Ripley wrote:
>
> On Fri, 17 Jan 2003, John Chambers wrote:
>
> > There are two main known differences from having methods attached:
> >
> > - the definition of class() changes, in particular no object ever has a
> > NULL class. If you have code tha
The current r-devel (aka R 1.7.0) now attaches the package "methods" by
default at startup.
A new option, "defaultPackages", is set to c("methods", "ctest") by
default, causing the .First in package base to require those two
packages at startup.
There are two main known differences from having me
95 matches
Mail list logo