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
53 views

1 answer to this question.

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
54 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,040 points
69 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
642 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,559 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
344 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
740 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
71 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
22 views