- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a point chart for categorical variable in R?
The point chart of a categorical has points corresponding to the categories just like the bar chart has bars. If we want to create point chart for categorical variable then we just need to use geom_point function of ggplot2 package. For example, if we have a data frame df that contains categorical column x and frequency column defined sd freq then the point chart for the categories in x can be ggplot(df,aes(x,freq))+geom_point().
Example
Consider the below data frame:
> set.seed(3521) > x<-sample(LETTERS[1:4],20,replace=TRUE) > freq<-rpois(20,8) > df<-data.frame(x,freq) > df
Output
x freq 1 B 2 2 C 12 3 A 8 4 D 12 5 C 8 6 C 9 7 B 11 8 B 10 9 B 8 10 C 6 11 D 5 12 B 10 13 D 6 14 B 7 15 B 14 16 C 7 17 A 7 18 A 6 19 A 6 20 A 7
Loading ggplot2 package and creating the point chart:
> library(ggplot2) > ggplot(df,aes(x,freq))+geom_point()
Output:
- Related Articles
- How to create a frequency column for categorical variable in an R data frame?
- How to create a point chart for cumulative sums using ggplot2 in R?
- How to create a categorical variable using a data frame column in R?
- Create stacked bar plot for one categorical variable in an R dataframe.
- How to create a point chart with empty points using ggplot2 in R?
- How to create a table of sums of a discrete variable for two categorical variables in an R data frame?
- How to create a lagged variable in R for groups?
- How to create a point chart in R with alternative points having different shape?
- How to join the points of a point chart if X-axis values are categorical in R using ggplot2?
- How to create a point chart with point size increment based on the position of the point in R?
- How to find the summary by categorical variable in R?
- How to filter data frame by categorical variable in R?
- How to create a bar chart for single vector using ggplot2 in R?
- How to create a dummy variable in R?
- How to display mean for each group in point chart using ggplot2 in R?

Advertisements