library(lattice) set.seed(26) soc <- c('Infections and infestations', 'Neoplasms benign and malignant (incl. cysts and polyps)', 'Blood and the lymphatic system disorders', 'Immune system disorders', 'Endocrine disorders', 'Metabolism and nutrition disorders', 'Psychiatric disorders', 'Nervous system disorders', 'Eye disorders', 'Ear and labyrinth disorders', 'Cardiac disorders', 'Vascular disorders', 'Respiratory, thoracic and mediastinal disorders', 'Gastrointestinal disorders', 'Hepato-biliary disorders', 'Skin and subcutaneous tissue disorders', 'Musculoskeletal, connective tissue and bone disorders', 'Renal and urinary disorders', 'Pregnancy, puerperium and perinatal conditions', 'Reproductive system and breast disorders', 'Congenital and familial/genetic disorders', 'General disorders and administration site conditions', 'Investigations', 'Injury and poisoning', 'Surgical and medical procedures', 'Social circumstances') rate <- round(rnorm(length(soc), 8, 3), 1) ratec <- as.character(rate) # order by most frequent dat <- data.frame(soc, rate, ratec) sortmat <- function (Mat, Sort) { m <- do.call("order", as.data.frame(Mat[, Sort])) Mat[m, ] } sdat <- sortmat(dat, 2) # Set up the plot levpt <- unique(sdat$soc) npt <- length(levpt) png('C:/Research/Graphics/Graphs4Display/webpages/classes/pages/images/DotplotSOC.png', width=600, height=400) # Set-up Layout mylayout <- layout(matrix(c(1,2,3), byrow=TRUE, ncol=3), widths=c(4/10,1/10,5/10)) par(mar=c(5,1,2,0)) plot(x=c(0,max(nchar(as.character(sdat$soc)))+1), y=c(.9,npt+.1), ann=FALSE, axes=FALSE, type='n') title('System Organ Classification') text(x=rep(max(nchar(as.character(sdat$soc))), npt), y=1:npt, label=sdat$soc, adj=c(1,0.5)) par(mar=c(5,0,2,0)) plot(x=c(0,1), y=c(.9,npt+.1), ann=FALSE, axes=FALSE, type='n') title('%') text(x=rep(.5, npt), y=1:npt, label=sdat$ratec, adj=c(0.5,0.5)) par(mar=c(5,0,2,2)) plot(x=c(0,max(sdat$rate)+.25), y=c(.9,npt+.1), type='n', axes=FALSE, xlab='Relative Frequency of an Event (%)', ylab='', ylim=c(.9,npt+.1)) axis(1) #box() abline(v=c(0,5,10,15), col='grey80', lty=3, lwd=2) for(i in 1:npt){ lines(c(0,sdat$rate[i]),c(i,i), lty=1, col='grey60', lwd=2) } points(sdat$rate, 1:npt, pch=16, col='black', cex=2) dev.off()