gpt4 book ai didi

papaja - 在 papaja::apa_table 中将值削减到阈值以下的选项

转载 作者:行者123 更新时间:2023-12-04 09:50:43 25 4
gpt4 key购买 nike

我不知道如何有选择地打印表格中高于或低于某个值的值。我正在寻找的是 Revelle 的 psych 包中的“cut”。 MWE 下面。

library("psych")
library("psychTools")
derp <- fa(ability, nfactors=3)
print(derp, cut=0.5) #removes all loadings smaller than 0.5
derp <- print(derp, cut=0.5) #apa_table still doesn't print like this

问题是,如何将那个 cut 添加到 apa_table 中?打印 apa_table(derp) 会打印整个表,包括所有值。

最佳答案

psych 中的print 方法不返回格式化的载荷,而只返回计算的方差表。但是,您可以通过手动格式化加载表来获得所需的结果:

library("psych")
library("psychTools")
derp <- fa(ability, nfactors=3)

# Class `loadings` cannot be coerced to data.frame or matrix
class(derp$Structure)
  [1] "loadings"
# Class `matrix` is supported by apa_table()
derp_loadings <- unclass(derp$Structure)
class(derp_loadings)
  [1] "matrix"
# Remove values below "cut"
derp_loadings[derp_loadings < 0.5] <- NA

colnames(derp_loadings) <- paste("Factor", 1:3)

apa_table(
derp_loadings
, caption = "Factor loadings"
, added_stub_head = "Item"
, format = "pandoc" # Omit this in your R Markdown document
, format.args = list(na_string = "") # Don't print NA
)
*Factor loadings*
Item Factor 1 Factor 2 Factor 3
---------- --------- --------- ---------
reason.4 0.60
reason.16
reason.17 0.65
reason.19
letter.7 0.61
letter.33 0.56
letter.34 0.65
letter.58
matrix.45
matrix.46
matrix.47
matrix.55
rotate.3 0.70
rotate.4 0.73
rotate.6 0.63
rotate.8 0.63

关于papaja - 在 papaja::apa_table 中将值削减到阈值以下的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62018314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com