xtable,更改列标题并添加标题

问题描述 投票:-1回答:1

我正在尝试为此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更改为“否”

enter image description here

r xtable
1个回答
0
投票

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")
© www.soinside.com 2019 - 2024. All rights reserved.