apply系列函数应该大部分都能在FUN后面传参数进来的,随便捏了个例子试了下
x <- c(
c(2.9, 3.0, 2.5, 2.6, 3.2), # normal subjects
c(3.8, 2.7, 4.0, 2.4), # with obstructive airway disease
c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosis
)
data <- matrix(rep(x, 10), ncol = 10)
group <- factor(
rep(1:3, c(5, 4, 5)),
labels = c(
"Normal subjects",
"Subjects with obstructive airway disease",
"Subjects with asbestosis"
)
)
apply(data, 2, kruskal.test, g = group)