When I was an R newbie, I was taught to load packages by using the command library(package). In my Linear Models class, the instructor likes to use require(package). This made me wonder, are the commands interchangeable? What’s the difference, and which command should I use?
Interchangeable commands . . .
The way most users will use these commands, most of the time, they are actually interchangeable. That is, if you are loading a library that has already been installed, and you are using the command outside of a function definition, then it makes no difference if you use “require” or “library.” They do the same thing.
… Well, almost interchangeable
Read on to understand the differences between the two. I end up doing something very similar to his code snippet for exactly the reason he describes. H/T R-Bloggers