You need to modify the postResample function, or create your own function that's similar, and then insert it into rfFuncs$summary. The default postResample function here below:
> postResample
function (pred, obs)
{
isNA <- is.na(pred)
pred <- pred[!isNA]
obs <- obs[!isNA]
if (!is.factor(obs) & is.numeric(obs)) {
if (length(obs) + length(pred) == 0) {
out <- rep(NA, 2)
}
else {
if (length(unique(pred)) < 2 || length(unique(obs)) <
2) {
resamplCor <- NA
}
else {
resamplCor <- try(cor(pred, obs, use = "pairwise.complete.obs"),
silent = TRUE)
if (class(resamplCor) == "try-error")
resamplCor <- NA
}
mse <- mean((pred - obs)^2)
n <- length(obs)
out <- c(sqrt(mse), resamplCor^2)
}
names(out) <- c("RMSE", "Rsquared")
}
else {
if (length(obs) + length(pred) == 0) {
out <- rep(NA, 2)
}
else {
pred <- factor(pred, levels = levels(obs))
requireNamespaceQuietStop("e1071")
out <- unlist(e1071::classAgreement(table(obs, pred)))[c("diag",
"kappa")]
}
names(out) <- c("Accuracy", "Kappa")
}
if (any(is.nan(out)))
out[is.nan(out)] <- NA
out
}
More specifically, since you are doing classification, you will need to modify the portion of postResample that says:
else {
if (length(obs) + length(pred) == 0) {
out <- rep(NA, 2)
}
else {
pred <- factor(pred, levels = levels(obs))
requireNamespaceQuietStop("e1071")
out <- unlist(e1071::classAgreement(table(obs, pred)))[c("diag",
"kappa")]
}
names(out) <- c("Accuracy", "Kappa")
}
After you've edited postResample, or created your own equivalent function, you can run:
rfFuncs$summary <- function (data, lev = NULL, model = NULL) {
if (is.character(data$obs))
data$obs <- factor(data$obs, levels = lev)
postResample(data[, "pred"], data[, "obs"])
}
Just make sure postResample has been edited or replace it with the name of your equivalent function.