我正在使用此代码绘制多重绘图:
multiplot <- function(plotlist=NULL, cols) {
require(grid)
# Make a list from the ... arguments and plotlist
plots <- c(plotlist)
numPlots = length(plots)
# Make the panel
plotCols = cols # Number of columns of plots
plotRows = ceiling(numPlots/plotCols) # Number of rows needed, calculated from # of cols
# Set up the page
grid.newpage()
pushViewport(viewport(layout = grid.layout(plotRows, plotCols)))
vplayout <- function(x, y)
viewport(layout.pos.row = x, layout.pos.col = y)
# Make each plot, in the correct location
for (i in 1:numPlots) {
curRow = ceiling(i/plotCols)
curCol = (i-1) %% plotCols + 1
print(plots[[i]], vp = vplayout(curRow, curCol ))
title(paste(product_name,'_ROC___AUC = ', mroc$auc))
}
}
致电
multiplot(list(ggplot1,ggplot2,ggplot3,ggplot4,ggplot5,ggplot6,linear_pred,roc_plot), cols=3)
我将成功呈现所有绘图(请参阅附件),除了最后创建的绘图:
rc <- roc(mnm.predict.test.class[[1]],mnm.predict.test.probs.max[[1]])
roc_plot <- plot(rc)
看起来像这样:
它是基于多项分类模型的ROC图,该模型由以下人员创建:
mnm <- multinom(formula = cut.rank ~ ., data = training.logist, trace = FALSE, maxit = 1000)
# predict on test set
mnm.predict.test.class <- as.data.frame(predict(mnm, newdata =testing.logist, type="class"))
mnm.predict.test.probs <- as.data.frame(predict(mnm, newdata =testing.logist, type="probs"))
mnm.predict.test.probs.max <- as.data.frame(apply(mnm.predict.test.probs, 1, max))
我的多重作用函数是否拒绝绘制ROC?