R 通过有效矩阵或手动方式显示紧凑的字母
我在R中运行多对比较。我使用生存包survminer。我正在使用以下函数: 成对_survdiff{survminer} 它给出了两两比较的显著性,但似乎没有办法给出结果的紧凑字母显示(CLD)。我在看一对19个关卡。最后,我把结果打印出来,手工输入excel,然后手工写信。但现在我需要再做一次,我希望有一个更简单的方法R 通过有效矩阵或手动方式显示紧凑的字母,r,pairwise,survminer,R,Pairwise,Survminer,我在R中运行多对比较。我使用生存包survminer。我正在使用以下函数: 成对_survdiff{survminer} 它给出了两两比较的显著性,但似乎没有办法给出结果的紧凑字母显示(CLD)。我在看一对19个关卡。最后,我把结果打印出来,手工输入excel,然后手工写信。但现在我需要再做一次,我希望有一个更简单的方法 我可以让R直接从成对的_survdiff{survminer}结果中执行CLD吗 暴露 有没有办法让it部门将结果打印到一个可以被电子表格读取的表格中 如果我手工制作逻辑矩阵
谢谢以下是来自
survminer
library(survminer)
library(multcomp)
library(tidyr)
data(myeloma)
res <- pairwise_survdiff(Surv(time, event) ~ molecular_group,
data = myeloma)
然后我们可以将res
对象中的p值重新排列到矩阵中mycomps
是成对比较的两侧矩阵。signif
向量符合逻辑,指示差异是否显著
comps <- as_tibble(res$p.value, rownames="row") %>%
pivot_longer(-row, names_to="col", values_to="p") %>%
na.omit()
mycomps <- as.matrix(comps[,1:2])
signif <- comps$p < .05
comps <- as_tibble(res$p.value, rownames="row") %>%
pivot_longer(-row, names_to="col", values_to="p") %>%
na.omit()
mycomps <- as.matrix(comps[,1:2])
signif <- comps$p < .05
multcomp:::insert_absorb(signif,
decreasing=FALSE,
comps=mycomps,
lvl_order=lvl_order)
# $Letters
# MAF Proliferation Cyclin D-2 MMSET Hyperdiploid
# "ab" "a" "b" "ab" "b"
# Low bone disease Cyclin D-1
# "ab" "ab"
#
# $monospacedLetters
# MAF Proliferation Cyclin D-2 MMSET Hyperdiploid
# "ab" "a " " b" "ab" " b"
# Low bone disease Cyclin D-1
# "ab" "ab"
#
# $LetterMatrix
# a b
# MAF TRUE TRUE
# Proliferation TRUE FALSE
# Cyclin D-2 FALSE TRUE
# MMSET TRUE TRUE
# Hyperdiploid FALSE TRUE
# Low bone disease TRUE TRUE
# Cyclin D-1 TRUE TRUE
#
# $aLetters
# [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v"
# [23] "w" "x" "y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R"
# [45] "S" "T" "U" "V" "W" "X" "Y" "Z"
#
# $aseparator
# [1] "."
#
# attr(,"class")
# [1] "multcompLetters"