I have a 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
Above data.frame means these sequences:
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)
I want to extract only non-subsequences like this:
1 2 3 4
A B C D
A E G
A K
A D J P
Is it possible to extract sequences which is not subsequence of any other sequence?
PS. Here is the code for making first 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')))