mycalc <- function(x, y, fun) x <- 1:5 y <- c(5, 2, 3, 10, 2) mycalc<- mycalc(x, y, fun) { if(fun == "sum") { o <- sum(x, y) } else if(fun == "subtract") { o <- (x-y) } else if(fun == "multiply") { o <- (x*y) } else if(fun == "divide") { o <- (x/y) } else { o <- paste("Not a recognized function") } return(o) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.