| Line 1... |
Line 1... |
| 1 |
% File src/library/methods/man/promptClass.Rd
|
1 |
% File src/library/methods/man/promptClass.Rd
|
| 2 |
% Part of the R package, https://www.R-project.org
|
2 |
% Part of the R package, https://www.R-project.org
|
| 3 |
% Copyright 1995-2007 R Core Team
|
3 |
% Copyright 1995-2016 R Core Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{promptClass}
|
6 |
\name{promptClass}
|
| 7 |
\alias{promptClass}
|
7 |
\alias{promptClass}
|
| 8 |
\title{Generate a Shell for Documentation of a Formal Class}
|
8 |
\title{Generate a Shell for Documentation of a Formal Class}
|
| Line 91... |
Line 91... |
| 91 |
\examples{
|
91 |
\examples{
|
| 92 |
\dontshow{
|
92 |
\dontshow{
|
| 93 |
## from setClass
|
93 |
## from setClass
|
| 94 |
## A simple class with two slots
|
94 |
## A simple class with two slots
|
| 95 |
setClass("track",
|
95 |
setClass("track",
|
| 96 |
representation(x="numeric", y="numeric"))
|
96 |
slots = c(x="numeric", y="numeric"))
|
| 97 |
## A class extending the previous, adding one more slot
|
97 |
## A class extending the previous, adding one more slot
|
| 98 |
setClass("trackCurve",
|
98 |
setClass("trackCurve", contains = "track",
|
| 99 |
representation("track", smooth = "numeric"))
|
99 |
slots = c(smooth = "numeric"))
|
| 100 |
## A class similar to "trackCurve", but with different structure
|
100 |
## A class similar to "trackCurve", but with different structure
|
| 101 |
## allowing matrices for the "y" and "smooth" slots
|
101 |
## allowing matrices for the "y" and "smooth" slots
|
| 102 |
setClass("trackMultiCurve",
|
102 |
setClass("trackMultiCurve",
|
| 103 |
representation(x="numeric", y="matrix", smooth="matrix"),
|
103 |
slots = c(x="numeric", y="matrix", smooth="matrix"),
|
| 104 |
prototype = list(x=numeric(), y=matrix(0,0,0), smooth= matrix(0,0,0)))
|
104 |
prototype = list(x=numeric(), y=matrix(0,0,0), smooth= matrix(0,0,0)))
|
| 105 |
|
105 |
|
| 106 |
setIs("trackMultiCurve", "trackCurve",
|
106 |
setIs("trackMultiCurve", "trackCurve",
|
| 107 |
test = function(obj) {ncol(slot(obj, "y")) == 1},
|
107 |
test = function(obj) {ncol(slot(obj, "y")) == 1},
|
| 108 |
coerce = function(obj) { new("trackCurve", x = slot(obj, "x"),
|
108 |
coerce = function(obj) { new("trackCurve", x = slot(obj, "x"),
|