Skip to content

Commit

Permalink
do show code required to run the example
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87652 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
smeyer committed Jan 27, 2025
1 parent 3a8c80f commit dd28cee
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/library/methods/man/setIs.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -254,30 +254,26 @@ 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

## 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",
Expand All @@ -294,7 +290,6 @@ setIs("trackCurve",
obj@smooth <- as.matrix(value@smooth)
obj})


\dontshow{
removeClass("trackMultiCurve")
removeClass("trackCurve")
Expand Down

0 comments on commit dd28cee

Please sign in to comment.