我是R的新手(我试过搜索;对不起,如果这是重复在其他地方!),我需要一些帮助,请!我试图编辑行名称在一个数据。帧:我从几个vcf文件开始,使用lapply()
创建一个列表列表,然后使用unlist()
将列表展平,并将提取的指示符组合到一个 Dataframe 中,但最终得到以下结果:
> row.names(mydataframe)
[1] "1_S1_annotated_filtered.vcf.gz1" "1_S1_annotated_filtered.vcf.gz2" "1_S1_annotated_filtered.vcf.gz3" "1_S1_annotated_filtered.vcf.gz6"
[5] "1_S1_annotated_filtered.vcf.gz7" "1_S1_annotated_filtered.vcf.gz8"
...
[457] "6_S6_annotated_filtered.vcf.gz877" "6_S6_annotated_filtered.vcf.gz888" "6_S6_annotated_filtered.vcf.gz907" "7_S7_annotated_filtered.vcf.gz309"
[461] "7_S7_annotated_filtered.vcf.gz354" "7_S7_annotated_filtered.vcf.gz477" "7_S7_annotated_filtered.vcf.gz485" "7_S7_annotated_filtered.vcf.gz537"
[465] "7_S7_annotated_filtered.vcf.gz569" "7_S7_annotated_filtered.vcf.gz575" "7_S7_annotated_filtered.vcf.gz721" "7_S7_annotated_filtered.vcf.gz871"
[469] "7_S7_annotated_filtered.vcf.gz892" "8_S8_annotated_filtered.vcf.gz136" "8_S8_annotated_filtered.vcf.gz191" "8_S8_annotated_filtered.vcf.gz967"
而我需要的是
> row.names(mydataframe)
[1] "S1" "S1" "S1" "S1"
[5] "S1" "S1" "S1" "S1"
....
[469] "S7" "S8" "S8" "S8"
有什么建议吗?提前感谢!
3条答案
按热度按时间bpzcxfmw1#
建议是:将信息存储在一个额外变量中。不能在 Dataframe 中存储非唯一的行名称:
给出:
因此,您可以:
但不能将其设置为行名。
aydmsdu92#
我会用途:
n1bvdmb63#
或者,将gsub与组捕获一起使用: