Can you please Difference between library () and require () functions in R language.

Category: R LanguageCan you please Difference between library () and require () functions in R language.
Editor">Editor Staff asked 2 years ago

Can you please Difference between library () and require () functions in R language.

1 Answers
Editor">Editor Staff answered 2 years ago

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)

}