如何在R中生成LaTeX以报告带有APA格式错误项的ANOVA?

时间:2019-07-29 13:05:44

标签: r latex anova

使用R生成带有APA格式错误项的ANOVA来报告LaTeX的最佳方法是什么?

我尝试过的软件包(apastats,apa)似乎只能处理 错误项:

library(apastats)
describe.aov(aov(yield ~  N*P*K, npk))

[1] "_F_(1, 16) = 6.16, _p_ = .025" "_F_(1, 16) = 0.27, _p_ = .608"
[3] "_F_(1, 16) = 3.10, _p_ = .097" "_F_(1, 16) = 0.69, _p_ = .418"
[5] "_F_(1, 16) = 1.08, _p_ = .314" "_F_(1, 16) = 0.02, _p_ = .902"
[7] "_F_(1, 16) = 1.20, _p_ = .289" "_F_(16, 16) = NA, _p_ =    NA"

describe.aov(aov(yield ~  N*P*K + Error(block), npk))
Error in vcov.default(mod, complete = FALSE) : 
  there is no vcov() method for models of class aovlist, listof

library(apa)
anova_apa(aov(yield ~  N*P*K, npk))
       Effect                                               
1 (Intercept) F(1, 16) = 2352.26, p < .001, petasq = .99 ***
2           N F(1, 16) =    6.16, p = .025, petasq = .28 *  
3           P F(1, 16) =    0.27, p = .608, petasq = .02    
4           K F(1, 16) =    3.10, p = .097, petasq = .16 .  
5         N:P F(1, 16) =    0.69, p = .418, petasq = .04    
6         N:K F(1, 16) =    1.08, p = .314, petasq = .06    
7         P:K F(1, 16) =    0.02, p = .902, petasq < .01    
8       N:P:K F(1, 16) =    1.20, p = .289, petasq = .07    

anova_apa(aov(yield ~  N*P*K + Error(block), npk))
Error: Result 1 must be a single double, not an integer vector of length 0
Call `rlang::last_error()` to see a backtrace
In addition: Warning message:
A call to `aov` does not support sphericity correction, continuing without correction of possible violated sphericity

1 个答案:

答案 0 :(得分:0)

使用papaja后,我设法得到了自己的东西

<<example, results='asis'>>=
m <- aov(yield ~  N*P*K + Error(block), npk)
library(papaja)
formatted <- apa_print(m)
apa_table(formatted$table)
@

The three-way interaction N x P x K was not significant, \Sexpr{formatted$full_result$N_P_K}.

enter image description here