One way is to use strapply in the gsubfn package. It is like apply in
that the first argument is the object (in both cases), the second is
the modifier (the margin in the case of apply and the regular
expression in the case of strapply) and a function (in both cases).
The parenthesized expressions
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 wrote:
> Greetings,
>
> I have a vector of values that are a word followed
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
# 2HP 42
# 3 Dell 91
HTH,
Jorge
On Wed, May 19, 2010 at 8:15 PM, Krishna Tat
3 matches
Mail list logo