How to divide 2 numbers in R?

How to divide 2 numbers in R?

How to divide 2 numbers in R?

This recipe helps you divide 2 numbers in R

Recipe Objective

How to divide two numbers in R ? The division of two numbers is an arithmetic operation of dividing two numbers and storing the output in a vector. The input values can be pre-defined or can be user-defined. The division operation can be done on a single number or a list of input values. This recipe performs the division of two numbers using the / operator..

Step 1 - Define two input vectors

x <- 100 y <- 20

Step 2- Divide the variables

Divide the two input vectors and store the ouput in a third output vector

z <- x/y print(paste("Division of two numbers is:",z))
"Output of the code is" : 5 

Step 3- User defined input vectors

Division of two numbers can also be done , with user defined values using the following syntax

a <- readline(prompt="enter the first input value : ") b <- readline(prompt="enter the second input value : ")
 "Output of the line is" :
enter the first input value : 100
enter the second input value : 20

The user defined input values are character type , they are converted into integer type for performing the division operation

a <- as.integer(a) b <- as.integer(b)

Step 4 - Add two user defined vectors

Adding two user defined input vectors and storing the output in a third vector

c <- a / b print(paste("Addition of user defined two numbers is:",c))
"Output of the code is" : Addition of two numbers is 5

Relevant Projects

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Inventory Demand Forecasting using Machine Learning in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Time Series Python Project using Greykite and Neural Prophet
In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.

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.

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

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.

Word2Vec and FastText Word Embedding with Gensim in Python
In this NLP Project, you will learn how to use the popular topic modelling library Gensim for implementing two state-of-the-art word embedding methods Word2Vec and FastText models.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Build a Face Recognition System in Python using FaceNet
In this deep learning project, you will build your own face recognition system in Python using OpenCV and FaceNet by extracting features from an image of a person's face.

Loan Eligibility Prediction in Python using
In this loan prediction project you will build predictive models in Python using to predict if an applicant is able to repay the loan or not.