How to do modulus operation in R?

How to do modulus operation in R?

How to do modulus operation in R?

This recipe helps you do modulus operation in R


Recipe Objective

Modulus Operation is an arithmetic operation in R which calculates the remainder after division of two numeric variables. This recipe demonstrates how to carry out the Modulus operation using two numeric variables while storing them in a third variable.

Step 1: Creating two numeric variables

We assign numbers to two variables

a = 10 b = 4

Step 2: Multiplying the two variables

We use the arithmetic operator " %% " to carry out this task and finally store the result in a third variable

# storing the result of the modulus arithmetic operation of the two numbers stored in variables 'a' and 'b' in 'result' result = a %% b # displaying the value stored in result result

Alternatively, we can also find the remainder after division of two numbers without assigning any variables to it. Just like a calculator. This is done simply by writing the operation as mentioned below and pressing 'enter'

10 %% 4

Relevant Projects

Predict Macro Economic Trends using Kaggle Financial Dataset
In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.

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.

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.

Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

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.

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.

Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

Build a Collaborative Filtering Recommender System in Python
Use the Amazon Reviews/Ratings dataset of 2 Million records to build a recommender system using memory-based collaborative filtering in Python.

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.