JackBoooooom
JackBoooooom

Reputation: 25

Can I have more than one ellipsis in one function

skewness <- function(x, ...){
    if(!is.numeric(x))
        stop("x is not numeric")
    mean((x-mean(x,...)),...)/(var(x,...))^2
}
x <- rnorm(100)  
x[3] <- NA
skewness(x,na.rm=T)
[1] NA

I can not get the answer that I want. So how to use the ellipsis correctly. Especially when it comes to more than one ellipsis that I want to use.

Upvotes: 0

Views: 88

Answers (1)

ricoderks
ricoderks

Reputation: 1619

You missed one ellipsis and I think there are is one to many ().

skewness <- function(x, ...){
    if(!is.numeric(x))
        stop("x is not numeric")
    mean(x - mean(x, ...), ...) / (var(x, ...))^2
}

Upvotes: 1

Related Questions