我需要更改ANOVA输出的行。我已经弄清楚了如何更改列。我是冰岛人,所以这可能会使您混淆。
library(tidyverse)
library(knitr)
options(scipen=999)
library(broom)
fervik_medalfermverd <- aov(fermetraverd ~ matssvaedi, data = urtak2)
kable(anova(fervik_medalfermverd), col.names = c("Frígráður", "Fervikasumma", "Meðalfervikassumma", "F-gildi", "P-gildi"))
如何更改行?
答案 0 :(得分:0)
也许您可以将方差分析对象转换为数据框/小标题,然后尝试执行以下操作:
library(tidyverse)
library(knitr)
options(scipen=999)
library(broom)
data(mpg)
tmp <- aov(cty ~ displ, data = mpg)
df <-
anova(tmp) %>%
as_tibble()
colnames(df) <- c("Frígráður", "Fervikasumma", "Meðalfervikassumma", "F-gildi", "P-gildi")
rownames(df) <- c("Label 1", "Label 2")
df %>%
kable()
这给出了:
| | Frígráður| Fervikasumma| Meðalfervikassumma| F-gildi| P-gildi|
|:-------|---------:|------------:|------------------:|--------:|-------:|
|Label 1 | 1| 2691.064| 2691.063754| 408.2482| 0|
|Label 2 | 232| 1529.282| 6.591735| NA| NA|