The R Project SVN R

Rev

Rev 25816 | Rev 42333 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25816 Rev 26000
Line 70... Line 70...
70
 
70
 
71
\examples{
71
\examples{
72
## representation for a new class with a directly define slot "smooth"
72
## representation for a new class with a directly define slot "smooth"
73
## which should be a "numeric" object, and extending class "track"
73
## which should be a "numeric" object, and extending class "track"
74
representation("track", smooth ="numeric")
74
representation("track", smooth ="numeric")
75
\testonly{
75
\dontshow{
76
prev <- getClassDef("class3")
76
prev <- getClassDef("class3")
77
setClass("class1", representation(a="numeric", b = "character"))
77
setClass("class1", representation(a="numeric", b = "character"))
78
setClass("class2", representation(a2 = "numeric", b = "numeric"))
78
setClass("class2", representation(a2 = "numeric", b = "numeric"))
79
try(setClass("class3", representation("class1", "class2")))
79
try(setClass("class3", representation("class1", "class2")))
80
{if(is.null(prev))
80
{if(is.null(prev))
Line 85... Line 85...
85
 
85
 
86
setClass("Character",representation("character"))
86
setClass("Character",representation("character"))
87
setClass("TypedCharacter",representation("Character",type="character"),
87
setClass("TypedCharacter",representation("Character",type="character"),
88
          prototype(character(0),type="plain"))
88
          prototype(character(0),type="plain"))
89
ttt <- new("TypedCharacter", "foo", type = "character")
89
ttt <- new("TypedCharacter", "foo", type = "character")
90
\testonly{
90
\dontshow{
91
stopifnot(identical(as(ttt, "character"), "foo"))
91
stopifnot(identical(as(ttt, "character"), "foo"))
92
}
92
}
93
 
93
 
94
setClass("num1", representation(comment = "character"),
94
setClass("num1", representation(comment = "character"),
95
         contains = "numeric",
95
         contains = "numeric",
96
         prototype = prototype(pi, comment = "Start with pi"))
96
         prototype = prototype(pi, comment = "Start with pi"))
97
 
97
 
98
\testonly{
98
\dontshow{
99
stopifnot(identical(new("num1"), new("num1", pi, comment = "Start with pi")))
99
stopifnot(identical(new("num1"), new("num1", pi, comment = "Start with pi")))
100
for(cl in c("num1", "TypedCharacter", "Character", "class2", "class1"))
100
for(cl in c("num1", "TypedCharacter", "Character", "class2", "class1"))
101
    removeClass(cl)
101
    removeClass(cl)
102
}
102
}
103
 
103