Thanks all for the prompt answers!!! All works perfectly!
up and running! Thanks!
"jim holtman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> This should do it for you:
>
>> x <- c("2564gc", "2367,GH", "2134 JHG")
>> x.sep <- gsub("([[:digit:]]+)[ ,]*([[:alpha:]]+)", "\\1 \\2",
This should do it for you:
> x <- c("2564gc", "2367,GH", "2134 JHG")
> x.sep <- gsub("([[:digit:]]+)[ ,]*([[:alpha:]]+)", "\\1 \\2", x)
> # now create separate values
> strsplit(x.sep, " ")
[[1]]
[1] "2564" "gc"
[[2]]
[1] "2367" "GH"
[[3]]
[1] "2134" "JHG"
>
On 3/5/08, sun <[EMAIL PROTECTED]>
t; "HK" "BF"
Cheers
Vincenzo
---
Vincenzo Luca Di Iorio
Consultant PME User support - GSK R&D Limited
-------------------
&q
Try this:
> library(gsubfn)
> x <- c("2324gz", "2567 HK", "3741,BF")
> strapply(x, "[[:digit:]]+|[[:alpha:]]+")
[[1]]
[1] "2324" "gz"
[[2]]
[1] "2567" "HK"
[[3]]
[1] "3741" "BF"
On Wed, Mar 5, 2008 at 9:51 AM, sun <[EMAIL PROTECTED]> wrote:
> I have strings contain postcode and letters, so
I have strings contain postcode and letters, some seperated with blank, some
with comma, and some hasn't seperated. eg, "2324gz" "2567 HK" "3741,BF"
I want to seperate the number and letters into two new variables.
I know this should be quite basic question, but searched on regex syntax and
th
5 matches
Mail list logo