方差分析表中的重命名因素

时间:2018-10-19 22:14:08

标签: r anova kable

我想重命名双向ANOVA表的输出。这是表格的代码:

```{r complete model anova weld}
weld$fgage = as.factor(weld$gage); weld$ftime = as.factor(weld$time)
wmoda = aov(weld$strength ~ weld$fgage*weld$ftime); waova = anova(wmoda) 
waova2 = round(waova, 2)
options(knitr.kable.NA = '-')
kable(waova2, col.names = c("Df", "Sum Sq", "Mean Sq", "F-Value", "P- 
Value"),
caption = '\\label{tab:waova}The two-way ANOVA table for the welding 
experiment (complete model).')
```

这是打印表格时的样子: ANOVA table

我想更改最左边一栏中的名称(weld $ fgage,weld $ ftime和weld fgage :weld ftime ),因为它们可以防止桌子变得更美观。

有人知道我会怎么做吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

对于此示例,您可以在

之前使用以下代码
```{r complete model anova weld}
weld$fgage = as.factor(weld$gage); weld$ftime = as.factor(weld$time)
wmoda = aov(weld$strength ~ weld$fgage*weld$ftime); waova = anova(wmoda) 
waova2 = round(waova, 2)
options(knitr.kable.NA = '-')
row.names(waova2)[1:3] = c("Factor A", "Factor B", "Interaction")
kable(waova2, col.names = c("Df", "Sum Sq", "Mean Sq", "F-Value", "P- 
Value"),
caption = '\\label{tab:waova}The two-way ANOVA table for the welding 
experiment (complete model).')
```