Skip to content

Data Science Tutorials

For Data Science Learners

  • Home
  • R
  • Statistics
  • Course
  • Machine Learning
  • Contact
  • About Us
  • Toggle search form
  • Confidence Intervals in R
    Confidence Intervals in R R
  • Top 10 Data Visualisation Tools
    Top 10 Data Visualisation Tools Every Data Science Enthusiast Must Know Course
  • best books about data analytics
    Best Books About Data Analytics Course
  • R Percentage by Group Calculation
    R Percentage by Group Calculation R
  • sorting in r
    Sorting in r: sort, order & rank R Functions R
  • Predict potential customer in R
    Predict potential customers in R R
  • How to Find Unmatched Records in R
    How to Find Unmatched Records in R R
  • Replace first match in R R
How to plot categorical data in R

Plot categorical data in R

Posted on March 9March 9 By Admin No Comments on Plot categorical data in R

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.

R

Post navigation

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

Related Posts

  • R Percentage by Group Calculation
    R Percentage by Group Calculation R
  • Quantiles by Group calculation in R
    Quantiles by Group calculation in R with examples R
  • How to Use Bold Font in
    How to Use Bold Font in R with Examples R
  • How do confidence intervals work
    How do confidence intervals work? R
  • How to perform MANOVA test in R
    How to perform the MANOVA test in R? R
  • In data science, what Is Open Innovation?
    In data science, what Is Open Innovation? R

Leave a Reply Cancel reply

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

  • Calculating Autocorrelation in R
  • Calculating Z-Scores in R: A Step-by-Step Guide
  • Descriptive Statistics in R
  • Multiple Plots to PDF in R
  • Run a specific code block in R
  • About Us
  • Contact
  • Disclaimer
  • Privacy Policy

https://www.r-bloggers.com

  • YouTube
  • Twitter
  • Facebook
  • Course
  • Excel
  • Machine Learning
  • Opensesame
  • R
  • Statistics

Check your inbox or spam folder to confirm your subscription.

  • How to do Pairwise Comparisons in R?
    How to do Pairwise Comparisons in R? R
  • A Side-by-Side Boxplot in R
    A Side-by-Side Boxplot in R: How to Do It R
  • How To Become a Business Intelligence Analyst
    How To Become a Business Intelligence Analyst Course
  • How to Calculate Relative Frequencies in R
    How to Calculate Relative Frequencies in R? R
  • How to compare the performance of different algorithms in R
    How to compare the performance of different algorithms in R? R
  • ggdogs on ggplot2
    ggdogs on ggplot2 R
  • droplevels in R with examples
    droplevels in R with examples R
  • Sort or Order Rank in R R

Privacy Policy

Copyright © 2024 Data Science Tutorials.

Powered by PressBook News WordPress theme