如何可能将QCA_mm类对象强制转换为表格?

huangapple go评论91阅读模式
英文:

How could it be possible coercing the QCA_mm class objvet into a table?

问题

我有这个表格,是从QCA包的truthTable()和minimize()函数的输出中生成的。

如何可能将QCA_mm类对象强制转换为表格?

我正在努力找到一种将这个QCA_min`对象强制转换为flextable的方法(或者我甚至可以使用另一种工具来创建表格)。重要的是,我想用足够的陈述来复制方程:

M1: ~DEV + ~STB <-> ~SURV

你有什么建议吗?

谢谢

library(QCA)
ttLCn <- truthTable(LC, ~SURV, sort.by = "incl, n", show.cases = TRUE)
pLCn <- minimize(ttLCn, include = "?", details = TRUE)
pLCn
英文:

I have this table, produced as output from the truthTable() and minimize() functions of the package QCA

如何可能将QCA_mm类对象强制转换为表格?

I am struggling with finding some method for coercing this QCA_min` object into a flextable (or I could even use another tool for creating a table). Important is fact the I would like to reproduce the equation with the sufficient statement:

M1: ~DEV + ~STB &lt;-&gt; ~SURV

Would you have any suggestions?

Thanks

library(QCA)
ttLCn &lt;- truthTable(LC, ~SURV, sort.by = &quot;incl, n&quot;, show.cases = TRUE)
pLCn &lt;- minimize(ttLCn, include = &quot;?&quot;, details = TRUE)
pLCn  

答案1

得分: 1

这不是很漂亮,但你可以看到值是如何通过查看QCA:::print.QCA_min函数创建的。这是提取信息的一种方法:

capture_qca <- function(x) {
  m <- NULL
  suppressMessages(trace(admisc::prettyString, exit = function() m <<- returnValue(), print=TRUE))
  capture.output(QCA:::print.QCA_min(x))
  list(m, x$IC$incl.cov)
}
capture_qca(pLCn)
# [[1]]
# [1] "~DEV + ~STB <-> ~SURV"
# 
# [[2]]
#      inclS PRI covS covU                      cases
# ~DEV     1   1  0.8  0.3 GR,PT,ES; IT,RO; HU,PL; EE
# ~STB     1   1  0.7  0.2    GR,PT,ES; HU,PL; AU; DE

这返回一个包含两个元素的列表。capture_qca(pLCn)[[1]] 是公式部分,capture_qca(pLCn)[[2]] 是一个数据框,你可以传递给 flextable。

英文:

This isn't exactly pretty but you can see how the values are created by looking at the QCA:::print.QCA_min function. Here's a way to extract that infromation

capture_qca &lt;- function(x) {
  m &lt;- NULL
  suppressMessages(trace(admisc::prettyString, exit = function() m &lt;&lt;- returnValue(), print=TRUE))
  capture.output(QCA:::print.QCA_min(x))
  list(m, x$IC$incl.cov)
}
capture_qca(pLCn)
# [[1]]
# [1] &quot;~DEV + ~STB &lt;-&gt; ~SURV&quot;
# 
# [[2]]
#      inclS PRI covS covU                      cases
# ~DEV     1   1  0.8  0.3 GR,PT,ES; IT,RO; HU,PL; EE
# ~STB     1   1  0.7  0.2    GR,PT,ES; HU,PL; AU; DE

This returns a list with two elements. capture_qca(pLCn)[[1]] is the formula part and capture_qca(pLCn)[[2]] is a data.frame you can pass to flextable.

huangapple
  • 本文由 发表于 2023年3月4日 06:38:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75632424.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定