Hi Krishna,

Here is a suggestion:

> x <- c("Apple12","HP42","Dell91")
> foo <- function(x) data.frame(brand = gsub("[0-9]", "", x), number =
gsub("[^0-9]", "", x))
> foo(x)
# brand number
# 1 Apple     12
# 2    HP     42
# 3  Dell     91

HTH,
Jorge


On Wed, May 19, 2010 at 8:15 PM, Krishna Tateneni <> wrote:

> Greetings,
>
> I have a vector of values that are a word followed by a number, e.g., x =
> c("Apple12","HP42","Dell91").  The goal is to split this vector into two
> vectors such that the first vector contains just the words and the second
> contains just the numbers.  I cannot use strsplit (or at least I do not
> know
> how) as there is no obvious separator.
>
> I can use sub to create a separator, e.g., y = sub("([[:digit:]])","
> \\1",x), and then use strsplit, but I thought more experienced R users may
> have a better solution.  I've spent some time with Google, but not turned
> up
> anything so far.
>
> Many thanks,
> --Krishna
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

