[R] Graphics function question

2008-07-29 Thread Peter Flom
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,

Re: [R] Graphics function question

2008-07-29 Thread Sarah Goslee
You can do it very easily using subsetting and a bit of paste(). I assumed you didn't need startdata and enddata after the plot has been made, but if you do you can change the last line of the function to return them. Sarah myfunction <- function(dataname) { # where dataname is a string, eg myf

Re: [R] Graphics function question

2008-07-29 Thread Marc Schwartz
on 07/29/2008 11:38 AM Peter Flom wrote: 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(startBReP3O

Re: [R] Graphics function question

2008-07-29 Thread Sarah Goslee
One clarification: I did the dirty and completely unprofessional thing, and assumed that this function would only be run in the workspace with all your data. I use functions like this frequently for something I need to do multiple times for a particular project, but will never do anywhere else, bu

Re: [R] Graphics function question

2008-07-29 Thread Marc Schwartz
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,