run <- FALSE root_dir <- paste(rep("../", 1), collapse = "") knitr::opts_chunk$set(comment = "#>", collapse = TRUE) knitr::opts_knit$set(root.dir = root_dir)
createInstance(of = "test_class") createInstance(of = "test_class", with = letters[1:3]) createInstance(of = "test_class", with = letters[1:3]) createInstance(of = "test_class", with = letters[1:3], attributes = list(attr_1 = TRUE, attr_2 = "yep!")) createInstance(of = "test_class", with = letters[1:3], attributes = list(my_attrs = list(attr_1 = TRUE, attr_2 = "yep!")))
foo <- function(x, ...) { UseMethod("foo", x) } foo.test_class <- function(x, context = NULL) { UseMethod("foo.test_class", context) } foo.test_class1.NULL <- function(x, context = NULL) { "Hello World!" } foo.test_class1.Context1 <- function(x, context) { "I'm the method for context 1" } foo.test_class1.Context2 <- function(x, context) { "I'm the method for context 2" }
x <- createInstance("test_class1") foo(x) ctxt_1 <- createInstance("Context1") foo(x = x, context = ctxt_1) ctxt_2 <- createInstance("Context2") foo(x = x, context = ctxt_2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.