Skip to content
Prev 299429 / 398503 Next

Splitting a character vector.

HI John,
If I understand the post, in your original data, there is a space between XXY and (.
If there was no space,

dd1? <-? c( "XXY(mat harry)","XXY(jim bob)", "CAMP(joe blow)", "ALP(max jack)")

#Rui's original code will produce
result<-strsplit(sub(close.par,"",dd1),open.par)
[[1]]
[1] "XXY(mat harry"

[[2]]
[1] "XXY(jim bob"

[[3]]
[1] "CAMP(joe blow"

[[4]]
[1] "ALP(max jack"


#But, if I wanted to get the result as in the original data strsplit,
result<-strsplit(sub(close.par," ",dd1),open.par)
[[1]]
[1] "XXY"??????? "mat harry "

[[2]]
[1] "XXY"????? "jim bob "

[[3]]
[1] "CAMP"????? "joe blow "

[[4]]
[1] "ALP"?????? "max jack "


A.K.






----- Original Message -----
From: John Kane <jrkrideau at inbox.com>
To: Rui Barradas <ruipbarradas at sapo.pt>
Cc: r-help at r-project.org
Sent: Saturday, July 7, 2012 6:33 PM
Subject: Re: [R] Splitting a character vector.

I think I'm geting it a bit. Anyway time to shut down and have a beer.? Life will be much nice tomorrow or Monday when I get back to cleaning up the data from that spreadsheet.? 

Many thanks and have a good weekend.

John Kane
Kingston ON Canada
____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails

______________________________________________
R-help at 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.