我正在尝试为此xtable添加标题
DATA5$Predict=predict(best.mod,newx=y2, type="class")
DATA5$armedornot2=ifelse(DATA5$armedornot!=1,"Yes","No")
DATA5$Predict=ifelse(DATA5$Predict <0.5, "No","Yes")
armedtable <- table(DATA5[,c("armedornot2","Predict")])
newtable<-cbind(armedtable,c(0,0))
xtable(newtable, caption=c("This is the title"), type="html", caption.placement="top")
但是,这不起作用。我也在尝试将下面的V2更改为“否”
将V2
更改为No
,将cbind(armedtable,c(0,0))
更改为cbind(armedtable, No = c(0,0))
至于您的标题,问题是印刷。 xtable
本身不带type
参数,而是print.xtable
决定类型(和caption.placement
)。试试这个:
print(xtable(newtable, caption=c("This is the title")),
type="html", caption.placement="top")