Try this: read.table(textConnection(gsub("([[:alpha:]])(\\d.*)", "\\1;\\2", x)), sep = ";")
or do.call(rbind, strsplit(gsub("([[:alpha:]])(\\d.*)", "\\1;\\2", x), ";")) On Wed, May 19, 2010 at 9:15 PM, Krishna Tateneni <taten...@gmail.com>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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.