Dear friends. I've made a very simple procedure to make Bland-Altman plots and it works OK except for the inability to take a variate as argument in annotation. I'm sure it is a very simple error, so if you have 5 seconds please tell me. Best wishes Troels bland <- function (x) #accepts two columns { mn <- 0.5*(x[,1]+x[,2]) diff <- x[,1]-x[,2] plot(mn,diff,pch=16,xlab="Mean",ylab="Difference", main = paste("Bland Altman plot",mn)) abline(h=mean(diff),lty=2) abline(h=mean(diff)+c(2,-2)*sqrt(var(diff))) } Troels look here: http://www.wired.com/wired/archive/8.04/joy.html -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Troels Ring <tring at mail1.stofanet.dk> writes:> bland <- function (x) #accepts two columns > { > mn <- 0.5*(x[,1]+x[,2]) > diff <- x[,1]-x[,2] > plot(mn,diff,pch=16,xlab="Mean",ylab="Difference", > main = paste("Bland Altman plot",mn)) > abline(h=mean(diff),lty=2) > abline(h=mean(diff)+c(2,-2)*sqrt(var(diff))) > }Er, what would you want to get? "mn" is a vector with potentially a lot of values in it, so neither paste(..., mn) or paste(...,mn,collapse=",") or anything in that vein looks particularly atttractive. Perhaps ... main = paste("Bland Altman plot of", substitute(x)) ... -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
As Peter helpfully pointed out mn was a vector, so here is the corrected version: bland <- function (x) #accepts two columns { mn <<- 0.5*(x[,1]+x[,2]) diff <- x[,1]-x[,2] plot(mn,diff,pch=16,xlab="Mean",ylab="Difference", main = "Bland Altman plot", sub= paste("Mean = ",formatC(mean(diff),digits=3))) abline(h=mean(diff),lty=2) abline(h=mean(diff)+c(2,-2)*sqrt(var(diff))) At 14:00 24-04-00, you wrote:>Dear friends. I've made a very simple procedure to make Bland-Altman plots >and it works OK except for the inability to take a variate as argument in >annotation. I'm sure it is a very simple error, so if you have 5 seconds >please tell me. >Best wishes >Troels > > bland <- function (x) #accepts two columns >{ >mn <- 0.5*(x[,1]+x[,2]) >diff <- x[,1]-x[,2] >plot(mn,diff,pch=16,xlab="Mean",ylab="Difference", >main = paste("Bland Altman plot",mn)) >abline(h=mean(diff),lty=2) >abline(h=mean(diff)+c(2,-2)*sqrt(var(diff))) >} >Troels > >look here: >http://www.wired.com/wired/archive/8.04/joy.html > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html >Send "info", "help", or "[un]subscribe" >(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._Troels Ring, MD Department of Nephrology Aalborg Hospital, Denmark tring at mail1.stofanet.dk -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._