我想使用一个字符串作为函数的参数,以便使用这个字符串来绘制结果,但是 R 绘制的是参数变量名称而不是它的字符串值。我尝试了不同的解决方案(diparse,as.character ...),但仍然没有解决方案。你有什么主意吗?
mcnemar_test <- function (c1,c2,class1, class2)
{
name1=label(class1)
name2=deparse(substitute(class2))
v1 = c1$encerts
v2 = c2$encerts
e00 = sum(ifelse(v1+v2==0,1,0)) #bad classification for both
e01 = sum(ifelse(v1<v2,1,0)) #bad classification for 1
e10 = sum(ifelse(v1>v2,1,0)) #bad classification for 2
e11 = sum(ifelse(v1+v2==2,1,0)) #good classification for both
matriu <- matrix(c(e00,e01,e10,e11),nrow = 2,
dimnames = list(name1 = c("Disapprove", "Approve"),
name2 = c("Disapprove", "Approve")))
print (matriu)
t <- mcnemar.test(matriu)
return (t)
}
mcnemar_test(classifiers.NaiveBayes,classifiers.CART,"aa","bb")
我想看到“aa”和“bb”,但看到“name1 和 name2”