The R Project SVN R

Rev

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

Rev 30912 Rev 33606
Line 66... Line 66...
66
  \code{\link{selectMethod}} will show you the method dispatched for a
66
  \code{\link{selectMethod}} will show you the method dispatched for a
67
  particular function and signature of classes for the arguments.
67
  particular function and signature of classes for the arguments.
68
}
68
}
69
\examples{
69
\examples{
70
\dontshow{
70
\dontshow{
71
setClass("track",
71
 setClass("track",
72
            representation(x="numeric", y="numeric"))
72
          representation(x="numeric", y="numeric"))
73
## First, with only one object as argument:
73
 ## First, with only one object as argument:
74
setMethod("plot", signature(x="track", y="missing"),
74
 setMethod("plot", signature(x="track", y="missing"),
75
  function(x,  y, ...) plot(slot(x, "x"), slot(x, "y"), ...)
75
           function(x,  y, ...) plot(slot(x, "x"), slot(x, "y"), ...))
76
)
-
 
77
## Second, plot the data from the track on the y-axis against anything
76
 ## Second, plot the data from the track on the y-axis against anything
78
## as the x data.
77
 ## as the x data.
79
setMethod("plot", signature(y = "track"),
78
 setMethod("plot", signature(y = "track"),
80
 function(x, y, ...) plot(x, slot(y, "y"), ...)
79
           function(x, y, ...) plot(x, slot(y, "y"), ...))
81
)
-
 
82
setMethod("plot", "track",
80
 setMethod("plot", "track",
83
 function(x, y, ...) plot(slot(x, "y"), y,  ...)
81
           function(x, y, ...) plot(slot(x, "y"), y,  ...))
84
)
-
 
85
}
82
}
86
## assuming the methods for plot
83
## Assuming the methods for plot
87
## are set up as in the documentation for setMethod,
84
## are set up as in the example of help(setMethod),
88
## print (without definitions) the methods that involve
85
## print (without definitions) the methods that involve class "track":
89
## class "track"
-
 
90
showMethods("plot", classes = "track")
86
showMethods("plot", classes = "track")
91
\dontrun{
87
\dontrun{
92
Function "plot":
88
Function "plot":
93
x = ANY, y = track
89
x = ANY, y = track
94
x = track, y = missing
90
x = track, y = missing