Differentiate between library() and require()?



Differentiate between library() and require()?..

Answer / Ravi Sahu

In R programming, both library() and require() are used for loading packages. However, they behave differently:
1. library(): Loads a package if it's not already loaded and adds it to the search path (.libPaths()). If the package is already loaded, it doesn't show any message.
2. require(): Also loads a package but throws an error if the package is not found in the search path. If the package is already loaded, it doesn't show any message.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More R Programming Interview Questions

Why we need data visualization in R?

1 Answers  


Why are the VCD and lattice packages used?

1 Answers  


How many tools for debugging present in r?

1 Answers  


Explain statistical functions performed by R?

1 Answers  


How will you create scatterplot matrices in r language?

1 Answers  


Explain how you can start the r commander gui?

1 Answers  


Explain about confusion matrix in r?

1 Answers  


Explain r graphics devices?

1 Answers  


How would you do a left and right join in r?

1 Answers  


What is recursion in r?

1 Answers  


Name the functions which help in importing data from other applications in R?

1 Answers  


How many data structures R has?

1 Answers  


Categories