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
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: