Just a quick follow up to my own post here. In offline exchanges, Peter noted a typo in the call to plot(), where I was missing the final ")". Also, I had the order of the unnamed arguments to segments() off.

Here is the corrected code, with some additional teaks:


plotdiffs <- function(x, y, startage, endage, decline)
{
  startvar <- x - y
  endvar <- x

  s1 <- seq(47, 89, length = 10)

  ymin <- min(startvar, endvar, na.rm = TRUE)
  ymax <- max(startvar, endvar, na.rm = TRUE)

  s2 <- seq(ymin, ymax, length = 10)

  label <- gsub("^.+\\$", "", deparse(substitute(x)))

  plot(s1, s2, type = "n",  xlab = "Age",  ylab = label,
       main = paste("Age, decline and", label))

  segments(startage, startvar, endage, endvar,  col = decline)

  legend("topleft", legend = c("Stable", "Decline"), lty = 1,
         col = c(1, 2))
}



Marc

______________________________________________
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.

Reply via email to