
170 R Programming for Bioinformatics
In the code below, we demonstrate the use of the suffix and prefix functions.
Notice that white space is considered to be part of the prefix or suffix.
> library("Biobase")
> str1 = c("not now", "not as hard as wow", "not something new")
> lcPrefix(str1)
[1] "not "
> lcSuffix(str1)
[1] "w"
For any string, then, the set of suffixes is of the same length as the string;
the first suffix is the whole string, the second suffix is the string starting at
the second letter, and so on. Consider the work biology, which has seven
characters, and hence seven suffixes:
1] biology
2] iology
3] ology
4] logy
5] ogy
6] gy
7] y
And these can then be sorted ...