I notice that lots of functions contain require() to attach a specific package. Some documents announce that require is mostly used within functions while library() should be used at the beginning. 
I have known that library() will throw out an error while require() will give a logical output when facing errors. But why should we mostly use require() within a function definition? 
            Asked
            
        
        
            Active
            
        
            Viewed 49 times
        
    1
            
            
        - 
                    2This post explains the difference between them https://stackoverflow.com/questions/5595512/what-is-the-difference-between-require-and-library – Ronak Shah Jun 20 '20 at 05:02
- 
                    @RonakShah Hi, thanks for the link. But I don't think the answers there are for this question. I know the differences between the two but I do not know the reason we should use require inside a function. – Jie Jun 20 '20 at 12:53
 
    