R 函数 - 主体未解释的默认值

R function - default value not inerpreted by the body

我的问题涉及以下 R 函数:

    but <- function(x, p = 0.95, FUN = mean, B = 1e4, smooth=FALSE, sd_smooth =1/sqrt(length(x)), ...)
{
  n <- length(x)
  bootmat <- replicate(B, sample(x, n, replace = TRUE))
  bootstat <- apply(bootmat, 2, FUN, ...)
  summary(bootstat); hist(bootstat)
  if (smooth) bootstat <- bootstat +rnorm(B, 0, sd_smooth)
  lo <- (1 - p)/2
  hi <- 1 - lo
  quantile(bootstat, c(lo, hi))
}

当我运行

but(1:10)

它 returns 均值的置信区间,正如预期的那样。 当我尝试时:

but(1:10, median)

发生错误:

Error in 1 - p : non-numeric argument to binary operator

好像默认的p(0.95)没有传递给函数体。如果能提示我的推理中出了什么问题,我将不胜感激。

因为有很多默认参数,其中一些是...,请按名称调用它们

but(1:10, FUN = median)
 2.5% 97.5% 
    3     8 

-输出