How to create a dotplot using lattice package in R?

This recipe helps you create a dotplot using lattice package in R

Recipe Objective

How to create a dotplot using lattice package in R? A dot plot or dot chart is a graphical representation of data points on the graph as circles (dots). A dot plot is similar to a bar plot with the exception of plotting dots instead of bars. Dot plots are used for quantitative/ categorical type of data. Lattice is a data visualization and graphics package in R. This recipe demonstrates an example of dot plots.

Step 1 - Install necessary package and library

install.packages("lattice") library(lattice)

Step 2 - Create a dataframe

data <- data.frame(values = c(10,20,30,40,50,60,70,80,90,100), count = c(5,5,5,5,6,6,6,7,7,7)) print(data)

 "Input data is : " 
   values count
1      10     5
2      20     5
3      30     5
4      40     5
5      50     6
6      60     6
7      70     6
8      80     7
9      90     7
10    100     7

Step 3 - Plot a dot plot

Syntax - dotplot(y ~ x , data , main , xlab, ylab) where, x , y - input variables data - input dataframe main -title of the plot xlab - title of the x axis ylab - title of the y axis

dotplot(values ~ count , data = data,main = "dot plot", xlab="x_data", ylab="y_data")

 " Output of the code is :"

What Users are saying..

profile image

Savvy Sahai

Data Science Intern, Capgemini
linkedin profile url

As a student looking to break into the field of data engineering and data science, one can get really confused as to which path to take. Very few ways to do it are Google, YouTube, etc. I was one of... Read More

Relevant Projects

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

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.

Recommender System Machine Learning Project for Beginners-2
Recommender System Machine Learning Project for Beginners Part 2- Learn how to build a recommender system for market basket analysis using association rule mining.

AWS Project to Build and Deploy LSTM Model with Sagemaker
In this AWS Sagemaker Project, you will learn to build a LSTM model on Sagemaker for sales forecasting while analyzing the impact of weather conditions on Sales.

Build a Text Classification Model with Attention Mechanism NLP
In this NLP Project, you will learn to build a multi class text classification model with attention mechanism.

Build an AI Chatbot from Scratch using Keras Sequential Model
In this NLP Project, you will learn how to build an AI Chatbot from Scratch using Keras Sequential Model.

Deploying Machine Learning Models with Flask for Beginners
In this MLOps on GCP project you will learn to deploy a sales forecasting ML Model using Flask.

Build a Credit Default Risk Prediction Model with LightGBM
In this Machine Learning Project, you will build a classification model for default prediction with LightGBM.

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.