0

我正在使用 RMarkdown 并试图在我的 Anova 表中获得显着效果,在最终的 pdf 文档中显示为粗体。在这种情况下,需要加粗的行是表的第二行(列名是第一行)。

使用papaja包:链接到 GitHub

这就是我进行方差分析的方式

library(apaTables)
library(MOTE)
data("iris")
ManCheck2.1 <- aov(formula = Sepal.Length ~ Sepal.Width * Petal.Length, data = iris) 
ManCheck2.1APA <- apa_print(ManCheck2.1)

这就是我准备明细表所做的

M2 <- apa.aov.table(ManCheck2.1, conf.level = .95)
M2table <- M2$table_body
# Delete the "(Intercept)" line:
M2table <- M2table[-1, ]
# Swap the p-values  with the formatted version from our apa_print() object IMPORTANT
M2table[2,6] <- as.character(ManCheck2.1APA$table$p[2])
M2table[1,6] <- as.character(ManCheck2.1APA$table$p[1])
M2table[3,6] <- as.character(ManCheck2.1APA$table$p[3])
# Rename the rows
M2table[ ,1] <- c("Company Motive", "CSR", "Company Motive * CSR", "Error")
colnames(M2table) <- c("Predictor", "$SS$", "$df$", "$MS$", "$F$", "$p$",
"$\\eta^{2}_{partial}$", "$\\eta^{2}_{partial}$ 95\\% CI")

这是在我的针织文档中显示表格的代码块。

apa_table(M2table, caption = "Effects of self- (versus other-oriented motive) and high CSR (versus neutral CSR) on perceived company motive", note = "Significant effects are bold", align = c("l", "r", "r", "r", "r", "r", "r", "c"), escape = F, row.names = F, # after manipulating the data frame, apa_table() started to show # the row numbers, so we had to choose "rownames = F" placement= "h")
4

1 回答 1

1

如果您只想扩大预测变量的名称,那么这就足够了:

M2table <- M2$table_body

M2table[ ,1] <- c("", "Company Motive", "CSR", "Company Motive * CSR", "Error")
cond <- M2table$p != "" & as.numeric(M2table$p)<.01 
M2table[cond,1] <- paste0("\\textbf{",M2table[cond,1] ,"}")
M2table <- M2table[-1, ]
# Rename the rows
# Swap the p-values  with the formatted version from our apa_print() object IMPORTANT
m2table[1:3, 6] <- ManCheck2.1APA$table$p

colnames(M2table) <- c("Predictor", "$SS$", "$df$", "$MS$", "$F$", "$p$",
"$\\eta^{2}_{partial}$", "$\\eta^{2}_{partial}$ 95\\% CI")

于 2020-10-22T14:07:12.560 回答