inst/resources/scripts/scoping.r

# program spuRs/resources/scripts/scoping.r
# Script to demonstrate the difference between passing and copying
# arguments.
# We use an artificial example with no real-world utility.

require(nlme)

fm1 <- lme(distance ~ age, data = Orthodont)
fm1$numIter <- 1

fm2 <- fm1

nochange <- function(x) {
  2 * x$numIter
  return(x)
}

change <- function(x) {
  x$numIter <- integer(2)
  return(x)
}

Try the spuRs package in your browser

Any scripts or data that you put into this service are public.

spuRs documentation built on May 2, 2019, 12:44 p.m.