Re: [Rd] failure in `setClass' examples

From: John Chambers <jmc_at_r-project.org>
Date: Tue 22 Nov 2005 - 20:08:54 GMT

There's nothing bad happening, and we should remove the setIs() example from the setClass() documentation.

If you run example(setIs), you will see a slightly different version of the same call to setIs(), but one that does not generate the warning (because it includes the argument replace= to setIs()). Comparing the two calls and looking at the documentation for setIs should explain where the warning comes from. But in any case, nothing to worry about.

John Chambers.

Sebastian Luque wrote:
> Hello,
>
> Below is what I got running the examples from `setClass'. Could somebody
> please help explain why the last `setIs' call is returning the warning and
> whether this is expected?
>
>
> R> setClass("track",
> + representation(x="numeric", y="numeric"))
> [1] "track"
> R> setClass("trackCurve",
> + representation("track", smooth = "numeric"))
> [1] "trackCurve"
> R> setClass("trackMultiCurve",
> + representation(x="numeric", y="matrix", smooth="matrix"),
> + prototype = list(x=numeric(), y=matrix(0,0,0),
> + smooth= matrix(0,0,0)))
> [1] "trackMultiCurve"
> R> try(setIs("trackMultiCurve", "trackCurve",
> + test = function(obj) {ncol(slot(obj, "y")) == 1}))
> Warning message:
> there is no automatic definition for as(object, "trackCurve") <- value when object has class "trackMultiCurve" and no 'replace' argument was supplied; replacement will be an error in: makeExtends(class1, class2, coerce, test, replace, by, classDef1 = classDef,
> R> setIs("trackMultiCurve", "trackCurve",
> + test = function(obj) {ncol(slot(obj, "y")) == 1},
> + coerce = function(obj) {
> + new("trackCurve",
> + x = slot(obj, "x"),
> + y = as.numeric(slot(obj,"y")),
> + smooth = as.numeric(slot(obj, "smooth")))
> + })
> Warning message:
> there is no automatic definition for as(object, "trackCurve") <- value when object has class "trackMultiCurve" and no 'replace' argument was supplied; replacement will be an error in: makeExtends(class1, class2, coerce, test, replace, by, classDef1 = classDef,
> R> version
> _
> platform i486-pc-linux-gnu
> arch i486
> os linux-gnu
> system i486, linux-gnu
> status
> major 2
> minor 2.0
> year 2005
> month 10
> day 06
> svn rev 35749
> language R
>
>
> Thanks in advance,
>



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Nov 23 07:32:17 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:34 GMT