How to install packages using devtools in R?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

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

1

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".

install.packages("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

devtools::install_cran("MASS")

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.

library(MASS)

Relevant Projects

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.

Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

Build a Similar Images Finder with Python, Keras, and Tensorflow
Build your own image similarity application using Python to search and find images of products that are similar to any given product. You will implement the K-Nearest Neighbor algorithm to find products with maximum similarity.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Demand prediction of driver availability using multistep time series analysis
In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.