0
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.

JackBoooooom
  • 25
  • 1
  • 6
  • See, for example, [here](http://stackoverflow.com/questions/5080972/using-multiple-ellipses-arguments-in-r) or [here](http://stackoverflow.com/questions/4124900/is-there-a-way-to-use-two-statements-in-a-function-in-r) – alexis_laz Feb 09 '17 at 14:59
  • Check your definition of skewness. – A. Webb Feb 09 '17 at 15:08
  • See `e1071::skewness`. Rather than all the ellipses passing, one might also consider including and handing the `na.rm` argument directly. – A. Webb Feb 09 '17 at 15:11
  • Yes but I just want to use it for an example. Thanks – JackBoooooom Feb 09 '17 at 15:28

1 Answers1

1

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
}
ricoderks
  • 1,619
  • 9
  • 13