提问人:TibialCuriosity 提问时间:5/5/2023 更新时间:5/5/2023 访问量:11
管理具有多个子列表的表
Managing a table with multiple sublists
问:
我正在做一些数据探索,并通过大量变量(~300)迭代方差分析,然后对重要发现进行成对比较。我知道从统计学的角度来看,这是不受欢迎的(我使用 Bonferroni 至少在一定程度上减少了错误),并且有更好的方法来分析数据,但这更像是一种探索性分析,以了解 4 组之间存在哪些一般差异。
运行成对测试后,输出将变成一个如下所示的表(为了便于阅读,仅显示 4 个变量)
List of 163
$ Var1 :List of 3
..$ comp : num [1:6, 1:6] 1 1 1 2 2 3 2 3 4 3 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:6] "Group" "Group" "psihat" "ci.lower" ...
..$ fnames: chr [1:4] "1" "3" "2" "4"
..$ call : language mcppb20(formula = .x ~ lasi_data_grouped$Group)
..- attr(*, "class")= chr "mcp1"
$ Var2 :List of 3
..$ comp : num [1:6, 1:6] 1 1 1 2 2 3 2 3 4 3 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:6] "Group" "Group" "psihat" "ci.lower" ...
..$ fnames: chr [1:4] "1" "3" "2" "4"
..$ call : language mcppb20(formula = .x ~ lasi_data_grouped$Group)
..- attr(*, "class")= chr "mcp1"
$ Var3 :List of 3
..$ comp : num [1:6, 1:6] 1 1 1 2 2 3 2 3 4 3 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:6] "Group" "Group" "psihat" "ci.lower" ...
..$ fnames: chr [1:4] "1" "3" "4" "2"
..$ call : language mcppb20(formula = .x ~ lasi_data_grouped$Group)
..- attr(*, "class")= chr "mcp1"
$ Var4 :List of 3
..$ comp : num [1:6, 1:6] 1 1 1 2 2 3 2 3 4 3 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:6] "Group" "Group" "psihat" "ci.lower" ...
..$ fnames: chr [1:4] "1" "3" "2" "4"
..$ call : language mcppb20(formula = .x ~ lasi_data_grouped$Group)
..- attr(*, "class")= chr "mcp1"
大多数有用的信息都存在于 $ comp 表中。我可以使用以下代码将其拉出来
results <- analysis %>%
map_df(pluck, "comp")
这看起来像
$ Var1 : num [1:6, 1:6] 1 1 1 2 2 3 2 3 4 3 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:6] "Group" "Group" "psihat" "ci.lower" ...
$ Var2 : num [1:6, 1:6] 1 1 1 2 2 3 2 3 4 3 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:6] "Group" "Group" "psihat" "ci.lower" ...
$ Var3 : num [1:6, 1:6] 1 1 1 2 2 3 2 3 4 3 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:6] "Group" "Group" "psihat" "ci.lower" ...
$ Var4 : num [1:6, 1:6] 1 1 1 2 2 3 2 3 4 3 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:6] "Group" "Group" "psihat" "ci.lower" ...
这就是我陷入困境的地方,因为我试图取消嵌套这些变量,尝试pivot_longer,尝试提升,但无法更改此表及其变量。
似乎表中的每一列都是 double 类型并包含一个表,因此进行进一步的分析或清理(使用 dplyr 或 ggplot)似乎不起作用,并且函数(例如 ends_with)不起作用。不幸的是,我无法共享原始数据以使其可重现,但任何指导或提示将不胜感激,因为我有点卡住了。
如果需要任何其他信息,请告诉我!
答: 暂无答案
下一个:跨多个子列表的循环计算
评论