我有兩個文件,file1包含file2的子字符串。我想匹配file1到file2並輸出匹配左側的部分,而不是匹配本身。我也想知道如何輸出比賽的權利,而不是比賽本身。 這是我的部分數據(這些字符串也可能不匹配,只是示例數據:輸出匹配字符串的左邊或右邊部分
文件1
ACUGUACAGGCCACUGCCUUGC
CUGCGCAAGCUACUGCCUUGCU
UGGAAUGUAAAGAAGUAUGUAU
CGAAUCAUUAUUUGCUGCUCUA
AUCACAUUGCCAGGGAUUACC
UUCACAGUGGCUAAGUUCUGC
文件2
CCAGGCUGAGGUAGUAGUUUGUACAGUUUGAGGGUCUAUGAUACCACCCGGUACAGGAGAUAACUGUACAGGCCACUGCCUUGCCAGG
CUGGCUGAGGUAGUAGUUUGUGCUGUUGGUCGGGUUGUGACAUUGCCCGCUGUGGAGAUAACUGCGCAAGCUACUGCCUUGCUAG
GCUUGGGACACAUACUUCUUUAUAUGCCCAUAUGAACCUGCUAAGCUAUGGAAUGUAAAGAAGUAUGUAUUUCAGGC
CUGUAGCAGCACAUCAUGGUUUACAUACUACAGUCAAGAUGCGAAUCAUUAUUUGCUGCUCUAG
GGCUGCUUGGGUUCCUGGCAUGCUGAUUUGUGACUUGAGAUUAAAAUCACAUUGCCAGGGAUUACCACGCAACC
例如:
文件1:
GCUGUGGAGAUAACUGCGC
文件2
CUGGCUGAGGUAGUAGUUUGUGCUGUUGGUCGGGUUGUGACAUUGCCCGCUGUGGAGAUAACUGCGCAAGC
輸出
CUGGCUGAGGUAGUAGUUUGUGCUGUUGGUCGGGUUGUGACAUUGCCC
@ GracieD:輸出的每個元素都是相同的。嘗試:ll = lapply(a,函數(i)sapply(strsplit(b,a [i]),「[[」,1));對於(我在2:長度(ll))打印(相同(ll [[i]],ll [[i-1]])) – rnso 2014-09-28 02:04:31
@rnso謝謝。更新。 – GracieD 2014-09-28 04:06:04