在data.frame中提取非子序列

时间:2016-07-20 09:00:11

标签: r dataframe extract sequence subsequence

我有一个data.frame:

1    2    3    4
A    B    C    D
A    B    C <NA>
A    C    D <NA>
A    C <NA> <NA>
A    D <NA> <NA>
A    E    G <NA>
A    G <NA> <NA>
A    K <NA> <NA>
A    D    J    P

以上data.frame表示这些序列:

Sequence    Is this Non-subsequence?
A-B-C-D     (non-subsequence)
A-B-C       (subsequence of A-B-C-D)
A-C-D       (subsequence of A-B-C-D)
A-C         (subsequence of A-B-C-D)
A-D         (subsequence of A-B-C-D)
A-E-G       (non-subsequence)
A-G         (subsequence of A-E-G)
A-K         (non-subsequence)
A-D-J-P     (non-subsequence)

我想只提取像这样的非子序列:

1    2    3    4
A    B    C    D
A    E    G
A    K
A    D    J    P

是否有可能提取不是任何其他序列后序列的序列?

PS。这是制作第一个data.frame的代码。

data.frame(rbind(
        c('A','B','C','D'),
        c('A','B','C', NA),
        c('A','C','D', NA),
        c('A','C',NA,NA),
        c('A','D',NA,NA),
        c('A','E','G',NA),
        c('A','G',NA,NA),
        c('A','K',NA,NA),
        c('A','D','J','P')))

0 个答案:

没有答案