replacing most require() calls with library()

http://yihui.name/en/2014/07/library-vs-require/