我正try 在我的R代码中使用两个包AFEX(Easy ANOVAS)和REMEPECC(Easy APA表格格式化).独立运行时,两者都能很好地工作.我使用repacc的函数"NICE_TABLE"创建了一个APA格式的表,该表可以导出到Word,但也可以在RStudio查看器中看到,如下所示:
但是,一旦我加载了AFEX,来自remepec的这个函数就不再向我显示表格,而是给我以下错误消息:
[1] header body footer col_keys caption blanks properties
<0 rows> (or 0-length row.names)
为了重现这个问题,这里有一个基于mtcars的基本示例,它也用于演示rempsyc.
library(rempsyc)
nice_table(
mtcars[1:3, ],
title = c("Table 1", "Motor Trend Car Road Tests"),
note = c(
"The data was extracted from the 1974 Motor Trend US magazine.",
"* p < .05, ** p < .01, *** p < .001"
)
)
#this one works
library(afex)
nice_table(
mtcars[1:3, ],
title = c("Table 1", "Motor Trend Car Road Tests"),
note = c(
"The data was extracted from the 1974 Motor Trend US magazine.",
"* p < .05, ** p < .01, *** p < .001"
)
)
#this one gives the error above and no table is created
detach("package:afex", unload = TRUE)
nice_table(
mtcars[1:3, ],
title = c("Table 1", "Motor Trend Car Road Tests"),
note = c(
"The data was extracted from the 1974 Motor Trend US magazine.",
"* p < .05, ** p < .01, *** p < .001"
)
)
#still doesn´t work
正如您所看到的,我的第一个解决方案是卸载AFEX以使其再次工作,但相同的错误仍然存在.指定程序包(REMEPECC::NICE_TABLE)也不起作用.让函数"NICE_TABLE"再次工作的唯一方法是完全关闭R/RStudio并从头重新启动.
我认为问题出在AFEX的"NICE"函数中,该函数输出"NICE_TABLE"类的数据帧(如手册所述).这似乎以某种方式覆盖了允许函数"NICE_TABLE"工作的某些默认方法.
我基本上只是在问,是否有人知道这两个包仍然可以在一个脚本中一起工作的方法.也许我错过了什么.提前谢谢您!