[R] How to specify function arguments that are used "in different places"

Gregor Gorjanc gregor.gorjanc at gmail.com
Mon May 1 15:00:51 CEST 2006


Hello!

Subject is not very clear, but I hope my question will be;) I wrote a
function, which produces a plot and I have problems with arguments. For
the sake of example let us consider that my function looks like this

myfunc <- function(x, points=FALSE, lines=FALSE, ...)
{
  ## x is an object that is being plotted
  plot(x$plotData, ...)
  ## one can also add some data on graph via points
  points(x$pointsData, ...)
  ## one can also add some data on graph via lines
  lines(x$linesData, ...)
}

My problem is in "..." argument. plot(), points() and lines() have so
many possible arguments, which is very nice, but how can I deal with
them in my scenario. For example, I might want to specify red color for
plot, blue for points and green for lines. Is it possible to handle such
a mixture, without specifiying zillion of arguments such as plotCol,
pointsCol, linesCol etc.? Perhaps something like ~ "points$..."?

Thanks!

-- 
Lep pozdrav / With regards,
    Gregor Gorjanc

----------------------------------------------------------------------
University of Ljubljana     PhD student
Biotechnical Faculty
Zootechnical Department     URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3                   mail: gregor.gorjanc <at> bfro.uni-lj.si

SI-1230 Domzale             tel: +386 (0)1 72 17 861
Slovenia, Europe            fax: +386 (0)1 72 17 888

----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.




More information about the R-help mailing list