[R] Justify axis labels in mosaic plot
Hello All, I'm trying to right-justify the y-axis labels in a mosaic plot from base R. I've tried too many commands (adj specifically) to list here and nothing works so far. I'm sure this could be done in the vcd or ggplot2 packages, but I would prefer to do it with mosaicplot in base R if at all possible and I suspect it is possible. Illustration code is below- I'm trying to make "q", "qwe", and "qwertyqwerty" right-justified instead of left. The prop.table and order bits are unnecessary for the sample but I need them for my actual analyses so I included them here in case that somehow affects the code needed. I would be incredibly appreciative of any help! #demo a<-c("qwertyqwerty", "qwertyqwerty", "qwertyqwerty", "qwe", "qwe", "qwe", "q", "q", "q") b<-c(1, 2, 3, 1, 1, 3, 2, 2, 3) demo<-data.frame(a, b) y<-table(demo) y<-as.table(y[order(rowSums(y)),]) y<-prop.table(y) plot(y, dir=c("h", "v"), las=1) Ryan Derickson VHA NCOD 513-247-4294 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to "vectorize" subsetting
I'm not trying to repost or spam everyone- I submitted this once before I subscribed so I just wanted to resend in case it didn't get disseminated. Hello all, I've tried to solve this for weeks and posted to other forums with little success- I'd appreciate any help from anyone. I have survey data grouped by facility and area (area is a collection of facilities). Questions are q1-q10. For each facility, I need to subset each item into the facility's responses, and the facility's area responses excluding the facility. This might illustrate it better: AreaFacility Q1... Q10 11 2 12 3 13 1 24 4 25 5 26 2 A<- Select Q1 for all Area=1 and Facility!=1; B<- Select Q1 for all Facility=1; A<- Select Q1 for all Area=1 and Facility!=2; B<- Select Q1 for all Facility=2; A<- Select Q1 for all Area=1 and Facility!=3; B<- Select Q1 for all Facility=3; ... A<- Select Q10 for all Area=2 and Facility!=6; B<- Select Q10 for all Facility=6; I know how to write the code to manually pull each subset, but I have a lot of facilities and areas that get renamed from year to year so I need to "vectorize" my code so each subset doesn't have to be explicitly called by area or facility name. Again, I would be incredibly appreciative of any help. I'm at a dead-end. Ryan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to "vectorize" subsetting
Hello all, I've tried to solve this for weeks and posted to other forums with little success- I'd appreciate any help from anyone. I have survey data grouped by facility and area (area is a collection of facilities). Questions are q1-q10. For each facility, I need to subset each item into the facility's responses, and the facility's area responses excluding the facility. This might illustrate it better: AreaFacilityQ1... Q10 1 1 2 1 2 3 1 3 1 2 4 4 2 5 5 2 6 2 A<- Select Q1 for all Area=1 and Facility!=1; B<- Select Q1 for all Facility=1; A<- Select Q1 for all Area=1 and Facility!=2; B<- Select Q1 for all Facility=2; A<- Select Q1 for all Area=1 and Facility!=3; B<- Select Q1 for all Facility=3; ... A<- Select Q10 for all Area=2 and Facility!=6; B<- Select Q10 for all Facility=6; I know how to write the code to manually pull each subset, but I have a lot of facilities and areas that get renamed from year to year so I need to "vectorize" my code so each subset doesn't have to be explicitly called by area or facility name. Again, I would be incredibly appreciative of any help. I'm at a dead-end. Ryan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.