# [R] subsetting character vector into groups of numerics

Patrick Connolly p.connolly at hortresearch.co.nz
Mon Oct 28 23:32:28 CET 2002

```I'm sure there's a simple way to do this, but I can only think of
complicated ones.

I have a number of character vectors that look something like this:

"12 78 23 9 76 43 2 15 41 81 92 5(92 12) (81 78 5 76 9 41) (23 2 15 43)"

I wish to get it into a list of numerical vectors like this:

\$Group
[1] 12 78 23 9 76 43 2 15 41 81 92 5

\$Subgroup1
[1] 92 12

\$Subgroup2
[1] 81 78 5 76 9 41

\$Subgroup3
[1] 23 2 15 43

I can't rely on the closing parenthesis as the last character in the
vector, though the subgroup could be clearly defined without it.
Numbers are obvious to the eye, but are not always separated from one
another consistently.  Part of the reason for this exercise is to
check that the Group is made up of the Subgroups with no elements
missing, so getting Group is not simply a matter of concatenating the
subgroups.

Ideas appreciated.

--
Patrick Connolly
HortResearch
Mt Albert
Auckland
New Zealand
Ph: +64-9 815 4200 x 7188
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

______________________________________________________
The contents of this e-mail are privileged and/or confidential to the
named recipient and are not to be used by any other person and/or