From dd28cee8dd4d88ae919e30d8e9010aa93a001e3c Mon Sep 17 00:00:00 2001 From: smeyer Date: Mon, 27 Jan 2025 15:35:02 +0000 Subject: [PATCH] do show code required to run the example git-svn-id: https://svn.r-project.org/R/trunk@87652 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/methods/man/setIs.Rd | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/library/methods/man/setIs.Rd b/src/library/methods/man/setIs.Rd index 6f9108fe9aa..da2ef81d05d 100644 --- a/src/library/methods/man/setIs.Rd +++ b/src/library/methods/man/setIs.Rd @@ -254,12 +254,6 @@ setIs(class1, class2, test=NULL, coerce=NULL, replace=NULL, } \examples{ -\dontshow{ -## A simple class with two slots -setClass("track", - slots = c(x="numeric", y="numeric")) -## A class extending the previous, adding one more slot -} ## Two examples of setIs() with coerce= and replace= arguments ## The first one works fairly well, because neither class has many ## inherited methods do be disturbed by the new inheritance @@ -267,17 +261,19 @@ setClass("track", ## The second example does NOT work well, because the new superclass, ## "factor", causes methods to be inherited that should not be. -## First example: -## a class definition (see \link{setClass} for class "track") +## First example (classes taken from examples in ?setClass): +## A simple class with two slots +setClass("track", slots = c(x="numeric", y="numeric")) +## A class extending the previous, adding one more slot setClass("trackCurve", contains = "track", - slots = c( smooth = "numeric")) + slots = c(smooth = "numeric")) ## A class similar to "trackCurve", but with different structure ## allowing matrices for the "y" and "smooth" slots setClass("trackMultiCurve", slots = c(x="numeric", y="matrix", smooth="matrix"), prototype = structure(list(), x=numeric(), y=matrix(0,0,0), + smooth=matrix(0,0,0))) - smooth= matrix(0,0,0))) ## Automatically convert an object from class "trackCurve" into ## "trackMultiCurve", by making the y, smooth slots into 1-column matrices setIs("trackCurve", @@ -294,7 +290,6 @@ setIs("trackCurve", obj@smooth <- as.matrix(value@smooth) obj}) - \dontshow{ removeClass("trackMultiCurve") removeClass("trackCurve")