After you are successful in installing useful packages, you should load the installed packages to use them. library()
function is helpful to load the installed packages. You should declare library(PACKAGE_NAME)
function once before using the functions in the package.
If you want to know the functions in the packages after installing the packages, pleases use library(help=PACKAGE_NAME)
. This will show the functions in the package.
require()
function is similar to library()
except for that require()
returns FALSE
when the package is not installed.
You can see the document of library()
function at the following link:
help(library)
in the console.
If you want to unload the packages, you can click out the checkbox in the packages in RStudio, or you can use detach()
function. The way to use detach()
can be found when typing help(detach)
in your R workspace.
library()
function works. %>%
shows error before loading dplyr package.
Length <- iris$Sepal.Length
# Length is a pre loaded vector in the environment.
head(Length)
# Use %>% before loading dplyr
Length %>% mean()
# load package dplyr
library(dplyr)
# Use %>% after loading dplyr package
Length %>% mean()