You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在R语言中将列表的列表合并为一个连续列表

合并多个cor向量为单一列表

方法一:直接拼接向量

先将你的三组cor数值分别定义为向量,再用c()按原始顺序拼接:

# 定义三组cor向量
cor_group1 <- c(0.10194656, 0.09795653, 0.18832356, 0.12265421, 0.09669338, 0.13781369, 0.16763787, 0.15137726, 0.10203826, 0.12649443, 0.16451622, 0.18429656, 0.21234920, 0.18254895, 0.10761731, 0.15354220, 0.13458206)
cor_group2 <- c(0.3332299, 0.3909873, 0.3631544)
cor_group3 <- c(0.11601617, 0.10834637, 0.10138418, 0.13864724, 0.17582967, 0.15005935, 0.05481153, 0.15443826, 0.08987235, 0.19109966, 0.13404778, 0.15816381)

# 合并为单一向量
merged_cor <- c(cor_group1, cor_group2, cor_group3)

方法二:从列表合并

如果你的数据原本是以列表形式存储(如你给出的控制台输出格式),可以用unlist()合并:

# 构建包含三组cor的列表
cor_list <- list(
  cor = cor_group1,
  cor = cor_group2,
  cor = cor_group3
)

# 合并列表元素为单一向量,忽略原名称
merged_cor <- unlist(cor_list, use.names = FALSE)

合并结果

执行后得到的merged_cor就是按原始顺序排列的所有数值:

print(merged_cor)
# 输出:
#  [1] 0.10194656 0.09795653 0.18832356 0.12265421 0.09669338 0.13781369 0.16763787 0.15137726 0.10203826 0.12649443 0.16451622
# [12] 0.18429656 0.21234920 0.18254895 0.10761731 0.15354220 0.13458206 0.33322990 0.39098730 0.36315440 0.11601617 0.10834637
# [23] 0.10138418 0.13864724 0.17582967 0.15005935 0.05481153 0.15443826 0.08987235 0.19109966 0.13404778 0.15816381

内容的提问来源于stack exchange,提问作者new2compgenomics

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 06:05:15