library(): load installed packages

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:

  • library() : load installed pacakges
  • Also, this document is popped up when you type 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.

    Instruction

    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()

    Previous: 1-7 | install.packages(): install packages easily

    Next: 1-9 | example(): Run the examples in the help document

    Back to Main