'Is there an R Function to add a scale/ axis to a mosaic plot
Im trying to make a mosaic plot and it currently looks like this. It does not have an axis for some reason even though I have data and added the variables already. I was wondering if someone knew how to do this? Thanks
assignment$pet <- ifelse(assignment$pet == 0, "no", "yes")
mosaicplot(~ pet + change,
data = assignment,
color = TRUE, las = 1,
xlab="Ownership of pets",
ylab="Degree of connectivity",
main="The degree of change in social connectivity vs the ownership of pets")
I edited the change variable like this:
knitr::opts_chunk$set(echo = TRUE)
assignment$change[assignment$time1<assignment$time2]<-"increase"
assignment$change[assignment$time1>assignment$time2]<-"decrease"
assignment$change[assignment$time1==assignment$time2]<-"no change"
the spreadsheet file looks like this btw
Solution 1:[1]
The spineplot()
function in R is a special flavor of mosaic plot that shades by the "dependent" variable and also adds a second y-axis with the corresponding cumulative proportions:
spineplot(change ~ pet, data = assignment)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Achim Zeileis |