This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to help understanding of S3 object-oriented programming | |
# in R using classes and methods | |
# Constructor functions for various classes of animal | |
pig <- function() structure(list(), class=c("pig", "animal")) | |
dog <- function() structure(list(), class=c("dog", "animal")) | |
cat <- function() structure(list(), class=c("cat", "animal")) | |
makeSound <- function(x) UseMethod("makeSound") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A tutorial navigates through a series of states, either manually, with | |
# nxt(), prv(), jmp() etc, or automatically, by using addTaskCallback() and | |
# checking that preconditions are met. | |
# | |
# Each state has: | |
# * a message | |
# * a next state (a function name) | |
# (eventually may have multiple next named states) | |
# * an auto test | |
# |