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<-1while(i<n) {
if (identical(e, emptyenv()))
breake<- 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
The text was updated successfully, but these errors were encountered:
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:
The text was updated successfully, but these errors were encountered: