[[1]]
Estimate Pr(>|t|)
(Intercept) 0.2105808 0.557122939
Rcm[, 1] -0.1825941 0.248647764
Rcm[, 2] -0.5519795 0.005074583
[[2]]
Estimate Pr(>|t|)
(Intercept) 0.7394133 0.08712924
Rcm[, 1] -0.5268179 0.00586987
Rcm[, 2] -0.4915758 0.03754552
但我只需要所有矩阵的P值列。我该怎么做?
答案 0 :(得分:1)
我们可以使用lapply
将第二列提取为list
lapply(pv, function(x) x[,2, drop = FALSE])
假设,如果我们想要它作为单个矩阵,则可以使用sapply
sapply(pv, function(x) x[,2, drop = FALSE])
# [,1] [,2]
#[1,] 0.557122939 0.08712924
#[2,] 0.248647764 0.00586987
#[3,] 0.005074583 0.03754552
pv <- list(structure(c(0.2105808, -0.1825941, -0.5519795, 0.557122939,
0.248647764, 0.005074583), .Dim = c(3L, 2L), .Dimnames = list(
c("(Intercept)", "Rcm[, 1]", "Rcm[, 2]"), c("Estimate", "Pr(>|t|)"
))), structure(c(0.7394133, -0.5268179, -0.4915758, 0.08712924,
0.00586987, 0.03754552), .Dim = c(3L, 2L), .Dimnames = list(c("(Intercept)",
"Rcm[, 1]", "Rcm[, 2]"), c("Estimate", "Pr(>|t|)"))))