私はデータフレームに列の1つを持っていますが、5番目の区切り記号 "。"の前に文字列の一部を削除したいと思います。最後の "。" .txtと私はそれを行う方法を知らない。R区切り文字の前に文字列を削除します
入力:
jhu-usc.edu_GBM.HumanMethylation450.6.lvl-3.TCGA-06-5415-01A-01D-1481-05.txt
jhu-usc.edu_BCD.HumanMethylation450.6.lvl-3.TCGA-06-5415-01A-01D-1482-05.txt
jhu-usc.edu_LGG.HumanMethylation450.6.lvl-3.TCGA-06-5415-01A-01D-1483-05.txt
jhu-usc.edu_LUAD.HumanMethylation450.6.lvl-3.TCGA-06-5415-01A-01D-1484-05.txt
jhu-usc.edu_LUAD.HumanMethylation450.6.lvl-3.TCGA-06-5415-01A-01D-1485-05.txt
jhu-usc.edu_BRCA.HumanMethylation450.6.lvl-3.TCGA-06-5415-01A-01D-1486-05.txt
jhu-usc.edu_GBM.HumanMethylation450.6.lvl-3.TCGA-06-5415-01A-01D-1487-05.txt
jhu-usc.edu_PRCA.HumanMethylation450.6.lvl-3.TCGA-06-5415-01A-01D-1488-05.txt
所望の出力:
TCGA-06-5415-01A-01D-1481-05
TCGA-06-5415-01A-01D-1482-05
TCGA-06-5415-01A-01D-1483-05
TCGA-06-5415-01A-01D-1484-05
TCGA-06-5415-01A-01D-1485-05
TCGA-06-5415-01A-01D-1486-05
TCGA-06-5415-01A-01D-1487-05
TCGA-06-5415-01A-01D-1488-05
私が試した: sapply(strsplit(as.character(DFます$ V1)を、)、 '['、1 "" :5)
アドバイスをしてください。ありがとうございました。彼らは.txt
を持つすべてのエンドは、あなたが行うことができれば、テキストが
sub(".*(TCGA[^.]+).*", "\\1", str1)