Skip to content

Data Science Tutorials

  • Home
  • R
  • Statistics
  • Course
  • Machine Learning
  • Guest Blog
  • Contact
  • About Us
  • Toggle search form
  • How to Calculate Ratios in R
    How to Calculate Ratios in R R
  • Add Significance Level and Stars to Plot in R
    Add Significance Level and Stars to Plot in R R
  • How to Find Optimal Clusters in R, K-means clustering is one of the most widely used clustering techniques in machine learning.
    How to Find Optimal Clusters in R? R
  • How do confidence intervals work
    How do confidence intervals work? R
  • Top Data Modeling Tools for 2023
    Top Data Modeling Tools for 2023 Machine Learning
  • best books about data analytics
    Best Books About Data Analytics Course
  • Separate a data frame column into multiple columns
    Separate a data frame column into multiple columns-tidyr Part3 R
  • How to Get a Job as a Data Engineer
    How to Get a Job as a Data Engineer? R
How to plot categorical data in R

Plot categorical data in R

Posted on March 9March 9 By Jim No Comments on Plot categorical data in R
Tweet
Share
Share
Pin

Plot categorical data in R, mosaic, and association plots can graphically illustrate the association between two or more categorical variables (such as those data handled by contingency tables and log-linear modeling).

We will use a data set from Young and Winn, in which encountered eels were cross-classified according to species and location, to provide graphical summaries for categorical data.

How to Use Gather Function in R?-tidyr Part2 (datasciencetut.com)

Plot categorical data in R

Location<-c("A","B","C","D")
Species<-c("q1","q1","q2","q2")
Count<-c(12,13,14,12)
data<-data.frame(Location,Species,Count)
data
   Location Species Count
1        A      q1    12
2        B      q1    13
3        C      q2    14
4        D      q2    12
xtabs(Count~Location+Species,data)
Species
Location q1 q2
       A 12  0
       B 13  0
       C  0 14
       D  0 12

Mosiac Plot in R

Each cross-classification is represented by a mosaic of rectangles in the mosaic plot, whose sizes are proportional to the observed frequencies.

In addition, the rectangles can be shaded to reflect the magnitudes and significance of the residuals, thereby providing an indication of which cross-classifications contribute to a lack of independence.

Top Data Science Applications You Should Know 2023 (datasciencetut.com)

library(vcd)
strucplot(data1,gp=shading_max)

Association Plot in R

Cross-classifications are shown in association plots as rectangles with areas that correspond to the raw residuals and heights that represent the relative sizes and polarities of person residuals.

Similar to mosaic plots, residual magnitude, and significance can be reflected by shading.

Top 10 Data Visualisation Tools (datasciencetut.com)

assoc(data1,gp=shading_max)

Check your inbox or spam folder to confirm your subscription.

Tweet
Share
Share
Pin
R

Post navigation

Previous Post: Top Data Modeling Tools for 2023
Next Post: Defensive Programming Strategies in R

Related Posts

  • Filter Using Multiple Conditions in R
    Filter Using Multiple Conditions in R R
  • Crosstab calculation in R
    Crosstab calculation in R R
  • How to perform kruskal wallis test in r
    How to perform the Kruskal-Wallis test in R? R
  • Get the first value in each group in R
    Get the first value in each group in R? R
  • Quantiles by Group calculation in R
    Quantiles by Group calculation in R with examples R
  • How to Find Unmatched Records in R
    How to Find Unmatched Records in R R

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • About Us
  • Contact
  • Disclaimer
  • Guest Blog
  • Privacy Policy
  • YouTube
  • Twitter
  • Facebook
  • Defensive Programming Strategies in R
  • Plot categorical data in R
  • Top Data Modeling Tools for 2023
  • Ogive Graph in R
  • Is R or Python Better for Data Science in Bangalore

Check your inbox or spam folder to confirm your subscription.

  • Data Scientist Career Path Map in Finance
  • Is Python the ideal language for machine learning
  • Convert character string to name class object
  • How to play sound at end of R Script
  • Pattern Searching in R
  • How to perform kruskal wallis test in r
    How to perform the Kruskal-Wallis test in R? R
  • Arrange Data by Month in R
    Arrange Data by Month in R with example R
  • Predictive Modeling and Data Science
    Predictive Modeling and Data Science Machine Learning
  • How to Use Bold Font in
    How to Use Bold Font in R with Examples R
  • Subset rows based on their integer locations
    Subset rows based on their integer locations-slice in R R
  • Making games in R- Nara and eventloop Game Changers
    Making games in R- Nara and eventloop Game Changers Machine Learning
  • best books about data analytics
    Best Books to Learn Statistics for Data Science Course
  • Defensive Programming Strategies in R
    Defensive Programming Strategies in R Machine Learning

Copyright © 2023 Data Science Tutorials.

Powered by PressBook News WordPress theme