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
91 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
2 answers

What is the difference between %% and % in R programming?

HI, %% returns remainder in case of numeric ...READ MORE

answered Aug 26 in Data Analytics by anonymous
• 31,840 points
87 views
0 votes
1 answer

What is the difference between list and vector in R?

The difference are - A list holds different ...READ MORE

answered Oct 28 in Data Analytics by Cherukuri
• 31,840 points
98 views
0 votes
1 answer

What is the difference between merge and bind in R?

Merge function merges an arbitrarily large series ...READ MORE

answered Oct 28 in Data Analytics by Cherukuri
• 31,840 points
55 views
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
179 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
121 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,720 points
760 views
0 votes
2 answers

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,784 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
159 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
34 views