Errata / Additions

  • A simulation introduction to censoring in survival analysis
    https://thestatsgeek.com/2020/10/20/a-simulation-introduction-to-censoring-in-survival-analysis/

  • Generalized Additive Models (GAMs) in R
    https://noamross.github.io/gams-in-r-course/

  • find out which package a function comes from

    # get all method functions for the summary generic function
    methods(summary)
    
    # cannot directly see the code for summary.loess (the function is not 'exported')
    summary.loess
    
    # but can do so with getAnywhere()
    getAnywhere(summary.loess)
    
    # or if we know which package the function comes from
    stats:::summary.loess
    
    # but how do you know which package a function comes from???
    
    # can do this
    environmentName(environment(loess))
    
    # but this does not work for non-exported functions
    environmentName(environment(summary.loess))
    
    # try the where() function from the 'pryr' package
    
    # install.packages("pryr")
    library(pryr)
    where("loess")
    
    # also does not work for non-exported functions
    where("summary.loess")
    
    # my suggestion
    ff <- function(x) invisible(sapply(loadedNamespaces(), function(ns)
          if (exists(x, envir=asNamespace(ns), inherit=FALSE)) print(ns)))
    
    # try this out
    ff("loess")
    ff("summary.loess")
    
    # let's see what happens when there are two functions with the same name
    
    # (install) and load the 'dplyr' package
    #install.package("dplyr")
    library(dplyr)
    
    # note the messages about 'masking' (the dplyr package has some functions that
    # have the same name as functions that are already loaded)
    
    environmentName(environment(lag))
    where("lag")
    ff("lag")