Hello I have created a graph using the following commands:
<<< startBReP3O1T <- diffs$BReP3O1T - diffs$diff_BReP3O1T endBReP3O1T <- diffs$BReP3O1T x <- seq(47,89, length = 10) ymin <- min(min(startBReP3O1T), min(endBReP3O1T)) ymax <- max(max(startBReP3O1T), max(endBReP3O1T)) y <- seq(ymin, ymax, length = 10) plot(x,y, type = 'n', xlab = 'Age', ylab = 'BReP3O1T', main = 'Age, decline and BReP3O1T') segments(x0 = startage, x1 = endage, y0 = startBReP3O1T, y1 = endBReP3O1T, col = decline) legend('topleft', legend = c('Stable', 'Decline'), lty = 1, col = c(1,2)) >>>>> I would like to make this into a function. The only thing that changes is BReP3O1T. The problem is that sometimes this occurs as text (e.g. in ylab and main) sometimes after a $ (e.g. in the first two assigment statements), and sometimes it refers to the values (e.g. in ymin and ymax) Any help appreciated. Peter Peter L. Flom, PhD Brainscope, Inc. 212 263 7863 (MTW) 212 845 4485 (Th) 917 488 7176 (F) [[alternative HTML version deleted]] ______________________________________________ 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.