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

0 votes
I do not understand the difference between two of these. Please help someone.
Sep 5, 2018 in Data Analytics by shams
• 3,580 points
36 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
 library() require()
  • Library () function gives an error message display, if the desired package cannot be loaded.
  • Require () function is used inside function and throws a warning messages whenever a particular package is not Found
  • It loads the packages whether it is already loaded or not,
  • It just checks that it is loaded, or loads it if it isn’t (use in functions that rely on a certain package). The documentation explicitly states that neither function will reload an already loaded package.

Consider a related program for the above differentiation.

if(!require(package, character.only=T, quietly=T)) {

install.packages (package)

library(package, character.only=T)

}

For multiple packages you can use

for(package in c(”, ”)) {

if(!require(package, character.only=T, quietly=T)) {

install.packages (package)

library(package, character.only=T)

}

}

answered Sep 5, 2018 by zombie
• 3,690 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

Structured query language (SQL) is a programming ...READ MORE

answered Aug 24, 2018 in Data Analytics by ANMOL
• 3,620 points
35 views
0 votes
1 answer

What is the difference between R and SPSS?

One of the main difference is R ...READ MORE

answered Dec 11, 2018 in Data Analytics by Maverick
• 10,000 points
53 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is size includes NaN ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,700 points
545 views
0 votes
1 answer

What is the difference between correlation and covariance?

Correlation and Co-variance both are used as ...READ MORE

answered Jul 24, 2018 in Data Analytics by ANMOL
• 3,620 points
1,419 views
0 votes
1 answer

What is the difference between random forest and decision trees?

The basic difference is that Random Forest ...READ MORE

answered Jul 30, 2018 in Data Analytics by ANMOL
• 3,620 points
271 views
0 votes
2 answers

What is the difference between LDA and PCA for dimensionality reduction?

Principal Component Analysis (PCA) is an unsupervised ...READ MORE

answered Mar 6 in Data Analytics by Seema
• 140 points
573 views
0 votes
1 answer

What is the difference between rnorm and runif functions ?

rnorm function generates "n" normal random numbers ...READ MORE

answered Oct 10, 2018 in Data Analytics by zombie
• 3,690 points
47 views
0 votes
1 answer

How to find out the package version which is loaded in R?

You can use sessionInfo() to accomplish that. > ...READ MORE

answered Apr 18, 2018 in Data Analytics by zombie
• 3,690 points
14 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.