[R] identify with mfcol=c(1,2)
    John Sorkin 
    JSorkin at grecc.umaryland.edu
       
    Thu Apr  5 01:48:25 CEST 2012
    
    
  
Please forgive my re-sending this question. I did not see any replies from my prior post. My apologies if I missed something.
I would like to have a figure with two graphs. This is easily accomplished using mfcol:
oldpar <- par(mfcol=c(1,2))
plot(x,y)
plot(z,x)
par(oldpar) 
I run into trouble if I try to use identify with the two plots. If, after identifying points on my first graph I hit the ESC key, or hitting stop menu bar of my R session, the system stops the identification process, but fails to give me my second graph. Is there a way to allow for the identification of points when one is plotting to graphs in a single graph window? My code follows.
plotter <- function(first,second) {
  # Allow for two plots in on graph window.
  oldpar<-par(mfcol=c(1,2))
  
  #Bland-Altman plot.
  plot((second+first)/2,second-first)
  abline(0,0)
  # Allow for indentification of extreme values.
  BAzap<-identify((second+first)/2,second-first,labels = seq_along(data$Line))
  print(BAzap)
  # Plot second as a function of first value.
  plot(first,second,main="Limin vs. Limin",xlab="First (cm^2)",ylab="Second (cm^3)")
  # Add identity line.
  abline(0,1,lty=2,col="red")
  # Allow for identification of extreme values.
  zap<-identify(first,second,labels = seq_along(data$Line))
  print(zap)
  # Add regression line.
  fit1<-lm(first~second)
  print(summary(fit1))
  abline(fit1)
  print(summary(fit1)$sigma)
  # reset par to default values.  
  par(oldpar)
}
plotter(first,second)
Thanks,
John
John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}
    
    
More information about the R-help
mailing list