MathsGee Answers is Zero-Rated (You do not need data to access) on: Telkom | Dimension Data | Rain | MWEB
First time here? Checkout the FAQs!
x

ASK - ANSWER - COMMENT - VOTE - DONATE


Network: Global | Joburg Libraries | MOOCs | StartUpTribe | Zimbabwe | Donate

MathsGee is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB

1 like 0 dislike
290 views

What is the difference between library() and require() functions in R language?



in Data Science by Diamond (67,402 points) | 290 views

1 Answer

0 like 0 dislike
Best answer

According to the documentation for both functions (accessed by putting a ? before the function name and hitting enter), require is used inside functions, as it outputs a warning and continues if the package is not found, whereas library will throw an error.

library(package) and require(package) both load the package with name package and put it on the search list. require is designed for use inside other functions; it returns FALSE and gives a warning (rather than an error as library() 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, call detach(unload = TRUE) or unloadNamespace first.) If you want to load a package without putting it on the search list, use requireNamespace.

 

by Diamond (67,402 points)

Related questions

0 like 0 dislike
0 answers
1 like 0 dislike
1 answer
0 like 0 dislike
1 answer

MathsGee Answers is a global, STEM-focused Q&A platform where you can ask people from all over the world educational questions for improved outcomes.



On MathsGee Answers, you can:


1. Ask questions
2. Answer questions
3. Comment on Answers
4. Vote on Questions and Answers
5. Donate to your favourite users

MathsGee Tools

Math Worksheet Generator

Math Algebra Solver

Trigonometry Simulations

Vectors Simulations

Matrix Arithmetic Simulations

Matrix Transformations Simulations

Quadratic Equations Simulations

Probability & Statistics Simulations

PHET Simulations

Visual Statistics

Interactive Courseware

ZeroEd Search Engine

Article Rewriter Tool

Word Counter Tool

Other Tools

STEM Gender Equality | ZOOM | Slack | eBook