I am confused by how list(...)
works in R and S-plus. For following code
pp <- function(x, ...) { print( length( list(...)))}
pp(1,,,1)
In S-Plus, it works, but in R, it gives "Error in print(length(list(...))) : argument is missing, with no default
"
I am more interest in how this works in R and how to get the value of list(...)
in R functions.
I'm not sure why that syntax is allowed in S-plus but not in R.
Here, though, is some R code that will have essentially the same effect:
pp <- function(x, ...) {
print(length(as.list(match.call(expand.dots=FALSE))[["..."]]))
}
pp(1,,,1)
# [1] 3
Alternatively, using a trick from here:
ppp <- function(x, ...) {
print(length(substitute(...())))
}
ppp(1,,,1)
# [1] 3