knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Note: This is not required reading. It will be helpful in understanding packages, scoping and masking, which any user will run into sooner or later but it is not crucial knowledge.
\newline
.GlobalEnv
or globalenv()
environment
parent.env
environment() parent.env(environment())
\newline
search
# search returns a character vector, it will be easier to read as a matrix cbind(search())
parent.env(as.environment('package:base'))
parent.env(emptyenv())
Most of the items on the search path are attached packages.
\newline
cbind(search()) library(lattice) cbind(search())
base
, utils
and datasets
are attached at the beginning of every session\newline
get
head(mtcars) mtcars <- matrix(rep("mtcars", 100), 20, 5) head(mtcars) mtc <- get("mtcars", pos = "package:datasets") head(mtc)
::
mtc <- datasets::mtcars head(mtc)
::
operator can also be used to access namespaces of packages that have been installed but not attachedhead(barley) head(lattice::barley)
\newline
Note that get
can scope an object with a character string rather than a symbol
<-
, ->
=
<-
assign
functionx
and the value in value
<<-
, ->>
This is by far not comprehensive, just some working knowledge. For more details check out R help pages for environment
, search
, attach
, library
. Read the Packages vignette before you do.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.