How to plot scatter plot using plot function in R?

How to plot scatter plot using plot function in R?

How to plot scatter plot using plot function in R?

This recipe helps you plot scatter plot using plot function in R

Recipe Objective

How to plot scatter plot using plot function in R? Scatter plots are graphs that represent a relation between an independent variable (x) and a dependent variable (y). The plot represents data on a 2 dimensional plane, where dependent variable (y) is plotted on the Y-axis and an independent variable (x) is plotted on the X-axis. Scatter plots are used to explain the correlation between the two variables. There are mainly 3 cases in scatter plot correlation – - Positive correlation - Negative correlation - No correlation Scatter plots help us understand and visualize the data properly. This recipe demonstrates an example of scatter plots.

Step 1 - Define the 2 vectors

x <- c(2,3,8,9,4,6,9,7,6,9) y <- c(3,9,5,6,8,6,5,8,9,3)

Step 2 - Plot the graph

Syntax for scatter plot - plot(x, y, main, xlab, ylab, xlim, ylim, axes) where, x - independent data points, y -independent data points, main - title of the correlation plot, xlab - title of the x axis, ylab - title of the y axis, xlim - limits for x axis data points, ylim - limits for y axis data points, axes - whether both the axes should be drawn on the plot.

plot(x,y,main="Correlation between x and y",xlab="x data points", ylab= "y data points", xlim=c(1,10),ylim=c(1,10))

Step 3 - Find the correlation

corelation <- cor(x,y) corelation # the scatter plot shows a negative correlation between the two variables.
 "Correlation between the two variables is :" -0.259788098433717 

Relevant Projects

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.

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Avocado Machine Learning Project Python for Price Prediction
In this ML Project, you will use the Avocado dataset to build a machine learning model to predict the average price of avocado which is continuous in nature based on region and varieties of avocado.

Build a Music Recommendation Algorithm using KKBox's Dataset
Music Recommendation Project using Machine Learning - Use the KKBox dataset to predict the chances of a user listening to a song again after their very first noticeable listening event.

Digit Recognition using CNN for MNIST Dataset in Python
In this deep learning project, you will build a convolutional neural network using MNIST dataset for handwritten digit recognition.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

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.

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.

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

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.