Re: [R] Splitting a character vector.

2012-07-09 Thread John Kane
Right, I see it now. Thanks. Who knows in another 100 years I may understand regex. John Kane Kingston ON Canada > -Original Message- > From: smartpink...@yahoo.com > Sent: Sat, 7 Jul 2012 16:19:54 -0700 (PDT) > To: jrkrid...@inbox.com > Subject: Re: [R] Splitting a c

Re: [R] Splitting a character vector.

2012-07-08 Thread John Kane
Works perfectly. Thank you very much indeed. John Kane Kingston ON Canada > -Original Message- > From: dwinsem...@comcast.net > Sent: Sat, 7 Jul 2012 21:45:58 -0400 > To: jrkrid...@inbox.com > Subject: Re: [R] Splitting a character vector. > > > On Jul 7, 201

Re: [R] Splitting a character vector.

2012-07-07 Thread David Winsemius
On Jul 7, 2012, at 5:37 PM, John Kane wrote: I am lousy at simple regex and I have not found a solution to a simple problem. I have a vector with some character values that I want to split. Sample data dd1 <- c( "XXY (mat harry)","XXY (jim bob)", "CAMP (joe blow)", "ALP (max jack)") De

Re: [R] Splitting a character vector.

2012-07-07 Thread arun
ub(close.par," ",dd1),open.par) > result [[1]] [1] "XXY"    "mat harry " [[2]] [1] "XXY"  "jim bob " [[3]] [1] "CAMP"  "joe blow " [[4]] [1] "ALP"   "max jack " A.K. - Original Me

Re: [R] Splitting a character vector.

2012-07-07 Thread John Kane
: ruipbarra...@sapo.pt > Sent: Sat, 07 Jul 2012 23:28:26 +0100 > To: jrkrid...@inbox.com > Subject: Re: [R] Splitting a character vector. > > The space is for a different reason, strsplit doesn't put the split > pattern in the result, so if a space is included it will be >

Re: [R] Splitting a character vector.

2012-07-07 Thread Rui Barradas
;s _exactly_ the same thing. Rui Barradas Em 07-07-2012 23:21, John Kane escreveu: Ah, I think Mark may have it. See my earlier post. Why the space? John Kane Kingston ON Canada -Original Message- From: ruipbarra...@sapo.pt Sent: Sat, 07 Jul 2012 23:12:46 +0100 To: marklee...@gmail.

Re: [R] Splitting a character vector.

2012-07-07 Thread John Kane
Ah, I think Mark may have it. See my earlier post. Why the space? John Kane Kingston ON Canada > -Original Message- > From: ruipbarra...@sapo.pt > Sent: Sat, 07 Jul 2012 23:12:46 +0100 > To: marklee...@gmail.com > Subject: Re: [R] Splitting a character vector. > >

Re: [R] Splitting a character vector.

2012-07-07 Thread John Kane
012 23:21:19 +0100 > To: jrkrid...@inbox.com > Subject: Re: [R] Splitting a character vector. > > It's an empty character string, meant to substitute nothing for > close.par, to get rid of it. > > Rui Barradas > > Em 07-07-2012 23:17, John Kane escreveu: >>

Re: [R] Splitting a character vector.

2012-07-07 Thread Rui Barradas
ot;, open.par I probably am just blind but I don't understand what it is doing. John Kane Kingston ON Canada -Original Message- From: ruipbarra...@sapo.pt Sent: Sat, 07 Jul 2012 23:08:19 +0100 To: jrkrid...@inbox.com Subject: Re: [R] Splitting a character vector. Hello, Sorry, but I

Re: [R] Splitting a character vector.

2012-07-07 Thread John Kane
age- > From: jdnew...@dcn.davis.ca.us > Sent: Sat, 07 Jul 2012 15:12:16 -0700 > To: ruipbarra...@sapo.pt, jrkrid...@inbox.com > Subject: Re: [R] Splitting a character vector. > > Just to clarify, the regex engine wants to see a \ before the ( if it is > to treat it as an ordinary

Re: [R] Splitting a character vector.

2012-07-07 Thread John Kane
m: ruipbarra...@sapo.pt > Sent: Sat, 07 Jul 2012 23:08:19 +0100 > To: jrkrid...@inbox.com > Subject: Re: [R] Splitting a character vector. > > Hello, > > Sorry, but I don't understand, you're asking about 4 single quotes, the > double quotes in open.par are just

Re: [R] Splitting a character vector.

2012-07-07 Thread Rui Barradas
the term. What is it doing? John Kane Kingston ON Canada -Original Message- From: ruipbarra...@sapo.pt <mailto:ruipbarra...@sapo.pt> Sent: Sat, 07 Jul 2012 22:55:41 +0100 To: jrkrid...@inbox.com <mai

Re: [R] Splitting a character vector.

2012-07-07 Thread Jeff Newmiller
Just to clarify, the regex engine wants to see a \ before the ( if it is to treat it as an ordinary character. However, the source code interpreter also treats \ as an escape character. In order to get a \ into the string, you have to escape it. So it takes two \ characters in source code to obt

Re: [R] Splitting a character vector.

2012-07-07 Thread Rui Barradas
.@sapo.pt Sent: Sat, 07 Jul 2012 22:55:41 +0100 To: jrkrid...@inbox.com Subject: Re: [R] Splitting a character vector. Hello, Try the following. open.par <- " \\(" # with a blank before '(' close.par <- "\\)" result <- strsplit(sub(close.par, ""

Re: [R] Splitting a character vector.

2012-07-07 Thread John Kane
n Kane Kingston ON Canada > -Original Message- > From: ruipbarra...@sapo.pt > Sent: Sat, 07 Jul 2012 22:55:41 +0100 > To: jrkrid...@inbox.com > Subject: Re: [R] Splitting a character vector. > > Hello, > > Try the following. > > open.par <- " \\("

Re: [R] Splitting a character vector.

2012-07-07 Thread Rui Barradas
Hello, Try the following. open.par <- " \\(" # with a blank before '(' close.par <- "\\)" result <- strsplit(sub(close.par, "", dd1), open.par) Why the two '\\'? Because '(' is a meta-character so it must be escaped. But '\' is a meta character so it must also be escaped. Then choose the r

[R] Splitting a character vector.

2012-07-07 Thread John Kane
I am lousy at simple regex and I have not found a solution to a simple problem. I have a vector with some character values that I want to split. Sample data dd1 <- c( "XXY (mat harry)","XXY (jim bob)", "CAMP (joe blow)", "ALP (max jack)") Desired result dd2 <- data.frame( xx = c("XXY", "XXY"