[R] List filtration
Johannes Graumann
johannes_graumann at web.de
Thu Feb 22 15:33:14 CET 2007
Hello R-ologists,
Imagine you have a list "list" like so:
>list
[[1]]
[1] "IPI00776145.1" "IPI00776187.1"
[[2]]
[1] "Something" "IPI00807764.1" "IPI00807887.1"
[[3]]
[1] "IPI00807764.1"
[[4]]
[1] "Somethingelse"
What I need to achieve is a filtered list "list2" like so:
>list2
[[1]]
[1] "IPI00776145.1"
[[2]]
[1] "IPI00807764.1"
[[3]]
[1] "IPI00807764.1"
So:
- if sublist-entry 1 start with "^IPI" make it the list-entry.
- otherwise chose the first "^IPI" sublist-entry present.
- delete the list-entry if not "^IPI" sublist-entry present.
Can anybody nudge me towards an elegant solution without looping - I have
LOTS of entries to process ...
Thanks for your Teachings,
Joh
More information about the R-help
mailing list