当我运行下面的代码时,我遇到了这个错误:类中的错误[[(cramersV == max(cramersV))]]:递归索引在2级失败。当我使用&时,问题似乎上升了#34;其中"在列表类的内部
new_var_cat=list()
new_var_cat[[1]]=new_var
V_Cramer_perclass=vector()
for(j in 2:91){
classes=list()
tbl=list()
cramersV=vector()
for(i in 1:(101-j)){
a_index=vector()
for(k in 0:(j-1)){a_index=c(a_index,which(new_var_cat[[j-1]]==i+k))}
temp=new_var_cat[[j-1]]
temp[a_index]=i
classes[[i]]=c(new_var_cat[[j-1]][-a_index],temp[a_index])
}
for(i in 1:(101-j)){
tbl[[i]]=table(classes[[i]],pb_default)
}
for(i in 1:(101-j)){
cramersV=c(cramersV,sqrt(unname(chisq.test(tbl[[i]])$statistic)/(n*(min(nrow(tbl[[i]])-1,ncol(tbl[[i]])-1)))))
}
new_var_cat[[j]]=classes[[which(cramersV==max(cramersV))]]
V_Cramer_perclass=c(V_Cramer_perclass,max(cramersV))
}