
Last chance! 50% off unlimited learning
Sale ends in
# NOT RUN {
?lapply
?"for" # but quotes/backticks are needed
?`+`
?women # information about data set "women"
# }
# NOT RUN {
require(methods)
## define a S4 generic function and some methods
combo <- function(x, y) c(x, y)
setGeneric("combo")
setMethod("combo", c("numeric", "numeric"), function(x, y) x+y)
## assume we have written some documentation
## for combo, and its methods ....
?combo # produces the function documentation
methods?combo # looks for the overall methods documentation
method?combo("numeric", "numeric") # documentation for the method above
?combo(1:10, rnorm(10)) # ... the same method, selected according to
# the arguments (one integer, the other numeric)
?combo(1:10, letters) # documentation for the default method
# }
Run the code above in your browser using DataLab