Skip to content

pass objects into "..." (dot dot dot)

7 messages · Ben quant, R. Michael Weylandt, Steve Lianoglou +1 more

#
Hi,
On Tue, May 15, 2012 at 12:46 PM, Ben quant <ccquant at gmail.com> wrote:
Calling `list(...)` will return a list as long as there are elements
caught in `...`

Does this help?

R> howMany <- function(...) {
  args <- list(...)
  cat("There are", length(args), "items passed in here\n")
}

R> howMany(1, 2, 3, 4)
There are 4 items passed in here

R> howMany(10, list(1:10))
There are 2 items passed in here

-steve
#
Are you perhaps looking for the do.call() construction?

z = Intervals(c(1,10))
y = Intervals(c(5,10))
x = Intervals(c(4,6))

do.call("interval_intersection", list(x,y,z))

Michael
On Tue, May 15, 2012 at 12:46 PM, Ben quant <ccquant at gmail.com> wrote:
#
Hi,
On Tue, May 15, 2012 at 1:38 PM, Ben quant <ccquant at gmail.com> wrote:
Hmm ... ok, I see. The interval_intersection function signature
suggests that this should work:

myIntersection <- function(...) {
  do.call(interval_intersection, unname(list(...)))
}

Or you can just make a list of intervals and do the same do.call mojo, ie:

do.call(interval_intersection, my.interval.list)

yay/nay?

-steve
#
You can also just pass the ... to the next function.  E.g., the following
two functions do the same thing:

  > myPaste1 <- function(...) paste(...)
  > myPaste2 <- function(...) do.call(paste, list(...))
  > myPaste1(1,2:3,4)
  [1] "1 2 4" "1 3 4"
  > myPaste2(1,2:3,4)
  [1] "1 2 4" "1 3 4"

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com