0 votes
in R Language by
Difference between library () and require () functions in R language.

1 Answer

0 votes
by

 library() require()

Library () function gives an error message display, if the desired package cannot be loaded. Require () function is used inside function and throws a warning messages whenever a particular package is not Found

It loads the packages whether it is already loaded or not, It just checks that it is loaded, or loads it if it isn’t (use in functions that rely on a certain package). The documentation explicitly states that neither function will reload an already loaded package.

Consider a related program for the above differentiation.

if(!require(package, character.only=T, quietly=T)) {

install.packages (package)

library(package, character.only=T)

}

For multiple packages you can use

for(package in c(”, ”)) {

if(!require(package, character.only=T, quietly=T)) {

install.packages (package)

library(package, character.only=T)

}

}

Related questions

0 votes
asked Feb 24, 2020 in R Language by rahuljain1
+2 votes
asked Jul 28, 2019 in R Language by Aarav2017
...