####### ------ Plot of the Number of Reports by SOC ------- ##### name <- c("Blood and the lymphatic system disorders", "Cardiac disorders", "Congenital and familial/genetic disorders", "Ear and labyrinth disorders", "Endocrine disorders", "Eye disorders", "Gastrointestinal disorders", "General disorders and administration site conditions", "Hepato-biliary disorders", "Immune system disorders", "Infections and infestations", "Injury, poisoning and procedural complications", "Investigations", "Metabolism and nutrition disorders", "Musculoskeletal and connective tissue disorders", "Neoplasms benign, malignant, and unspecified", "Nervous system disorders", "Pregnancy, puerperium and perinatal conditions", "Psychiatric disorders", "Renal and urinary disorders", "Reproductive system and breast disorders", "Respiratory, thoracic and mediastinal disorders", "Skin and subcutaneous tissue disorders", "Social circumstances", "Surgical and medical procedures", "Vascular disorders") freq <- c(0,100,0,325,0,270,860,875,0,85,60,250,470,60,290,0,1350,0,1475, 105,320,211,1050,5,0,90,100,340,0,450,30,350,815,850,35,330,70, 470,520,75,435,15,2850,3,1325,300,455,320,1825,5,4,335) grp <- rep(c('Consumers','Health Care Prof'), each=26) dat <- data.frame(name=rep(name,2), freq, grp) # Sort the factors based on HC frequencies library(gdata) sortmat <- function (Mat, Sort) { m <- do.call("order", as.data.frame(Mat[, Sort])) Mat[m, ] } dats <- sortmat(subset(dat, grp%in%'Consumers'), 2) dat1s <- data.frame(name=dats$name, freq=datsfreq, grp=rep(c('Consumers','Health Care Prof'), each=26)) oNames <- dats$name dat$name2 <- reorder(dat$name, new.order=oNames) #png('C:/Research/Graphics/Graphs4Display/webpages/classes/pages/images/ReportsBySOC.png', # width=900, height=625) new.back <- trellis.par.get("background") new.back$col <- "white" newcol <- trellis.par.get("superpose.symbol") newcol$col <- c('green4','blue') newcol$pch <- c(16,17,8) new.line <- trellis.par.get("superpose.line") new.line$col <- c('green4','blue') new.line$lty <- c(1,1,1,1) new.pan <- trellis.par.get("strip.background") new.pan$col <- c('gray90','white') trellis.par.set("background", new.back) trellis.par.set("superpose.symbol", newcol) trellis.par.set("superpose.line", new.line) trellis.par.set("strip.background",new.pan) dotplot(name2~freq, groups=grp, data=dat, xlab='Number of Reports', panel=function(x,y,...){ llines(c(0,0), c(-5,105), col='grey90', lty=2) llines(c(500,500), c(-5,105), col='grey90', lty=2) llines(c(1000,1000), c(-5,105), col='grey90', lty=2) llines(c(1500,1500), c(-5,105), col='grey90', lty=2) llines(c(2000,2000), c(-5,105), col='grey90', lty=2) llines(c(2500,2500), c(-5,105), col='grey90', lty=2) llines(c(3000,3000), c(-5,105), col='grey90', lty=2) panel.dotplot(x,y, col.line='grey70', ...) }, scales=list(x=list(at=seq(0,3000, 500), labels=seq(0,3000,500))), key=list(points=list( pch=trellis.par.get("superpose.symbol")$pch[1:2], col=trellis.par.get("superpose.symbol")$col[1:2]), text=list( lab=c('Consumers','Health Care Prof.'), col=trellis.par.get("superpose.symbol")$col[1:2]), columns=2, title='Source of Report'), sub='Patient Population 1' ) #dev.off()