Objects loaded via load_all() behave somewhat differently from loading those loaded with library().
With load_all(), the package environment is not a child of the global environment. But with library(), it is a child of the global environment.
This code will illustrate:
# This prints all parent environments, until it hits top (emptyenv)
printenvs <- function(e = parent.frame(), n = 100) {
cat(str(e, give.attr=F))
i <- 1
while(i < n) {
if (identical(e, emptyenv()))
break
e <- parent.env(e)
cat(str(e, give.attr=F))
i <- i+1
}
cat("\n")
return(e)
}
library(ggplot2)
debugonce(qplot)
qplot()
printenvs()
# <environment: R_GlobalEnv> is a parent
# === Might need to restart R to do this ===
library(devtools)
load_all('.')
debugonce(qplot)
qplot()
printenvs()
# <environment: R_GlobalEnv> is not a parent
Objects loaded via
load_all()behave somewhat differently from loading those loaded withlibrary().With
load_all(), the package environment is not a child of the global environment. But withlibrary(), it is a child of the global environment.This code will illustrate: