library()和require()均可载入R包,但如果一个包不存在:
执行到library()将会停止执行;
require()则会继续执行,并根据包的存在与否返回true或者false。
> test <- library("abc")
Error in library("abc") : there is no package called 'abc'
> test
Error: object 'test' not found
> test <- require("abc")
Loading required package: abc
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called 'abc'
> test
[1] FALSE