- 已编辑
gini <- function(x,correct=FALSE){
n=length(x)
fun=function(a,b)abs(a-b)
ifelse(correct,sum(outer(x,x,fun))/(2*n*(n-1)*mean(x)),sum(outer(x,x,fun))/2*n^2*mean(x)))
}
运行后提示:
Error: unexpected symbol in "gini <- function(x,correct=FALSE){n = length(x)fun"
刚学习R呢,想着按照书本实践一下,这个是基尼系数的公式,到这里走不下去了,没看懂是哪个符号有问题,求大神指导一下!!!谢谢啊