What is the difference between require() and library()?
?library
and you will see:
library(package)andrequire(package)both load the package with namepackageand put it on the search list.requireis designed for use inside other functions; it returnsFALSEand gives a warning (rather than an error aslibrary()does by default) if the package does not exist. Both functions check and update the list of currently loaded packages and do not reload a package which is already loaded. (If you want to reload such a package, calldetach(unload = TRUE)orunloadNamespacefirst.) If you want to load a package without putting it on the search list, userequireNamespace.