How to install packages using devtools in R?

How to install packages using devtools in R?

How to install packages using devtools in R?

This recipe helps you install packages using devtools in R


Recipe Objective

R packages consists of a collection of R functions, data sets and compiled code which adds value to the existing R-functionalities. They are stored in the 'library' directory in the R-environment and developed by the community. For Example, "dplyr" is one of the commonly used packages in R which adds further functionalities with respect to working with dataframes.

There already exists some default packages in the local directory 'library' on your machine when you install R. We can see all the default packages by using code : 'library()'. If we want to add a new package, we can use three ways to do it:

  1. Directly from CRAN repository;
  2. From .zip file on your local machine;
  3. Via devtools package

This recipe demonstrates the installation and loading of a package via devtools package. devtools package gives us the option to choose and install packages from different repositories like Bioconductor, Bitbucket, CRAN, local file, GitHub, URL, SVN etc.

Step 1: Installing devtool package

We use the command " install.packages("package_name") " to install from CRAN respository. Below shows the code for installation of "devtools".


After running the command, you might recieve some messages which is based on the OS, dependencies installed and the status of the package.

Step 2: Installing a package via devtools

We can use various functions of devtools package to install packages from different repositories like:

  1. install_bioc() = Bioconductor ;
  2. install_cran() = CRAN repository ;
  3. install_github() = GitHub ;
  4. install_svn() = SVN repository ;
  5. install_local() = local file ;
  6. install_url() = URL ;

Syntax: devtools::install_cran("package_name")

Below is the example of installing package from CRAN repository using devtools package


Step 3: Loading a package

We use the function "library()" to load the package. It is essential to load the package before we can use it in your code.


Relevant Projects

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Topic modelling using Kmeans clustering to group customer reviews
In this Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

Customer Market Basket Analysis using Apriori and Fpgrowth algorithms
In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.