1. Once you have the character vector from the regex, see ?strsplit to
get the strings on either side of the "->" .
You may have to fiddle a bit if one or the other side is empty.
You can then format the results as you like.
2. "Graphical representation similar to this" is too vague a
specificati
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
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 d
5 matches
Mail list logo