October 2017
Beginner to intermediate
236 pages
7h 38m
English
Let's take a look at the following steps:
robSum <- function(obj) { UseMethod("robSum") }
robSum.default <- function(obj){ cat("This is a generic function for the object class 'robustSummary'") }
# robustSummary robSum.robustSummary <- function(obj){ cat("Median ", median(obj), "\n") cat("Median Absolute Deviation (MAD)", mad(obj), "\n") cat("First Quartile (Q1)", as.numeric(quantile(obj, probs = 0.25)), "\n") cat("Third Quartile (Q3)", as.numeric(quantile(obj, probs = 0.75))) }