Re: [R] Split a string vector with '[ ]'

2014-06-09 Thread arun
Hi Alexsandro, Suppose if you have strings nw.str1 <- "[D][A|D]A:F[T|A:D]N[C|T]" nw.str2 <- "[D][A|D]A[T|A:D][C|T]NA{DG]P" you could use: library(qdap) as.vector(bracketXtract(nw.str1,"square",T)) #[1] "[D]" "[A|D]"   "[T|A:D]" "[C|T]"   as.vector(bracketXtract(nw.str2,"square",T)) #[1] "

Re: [R] Split a string vector with '[ ]'

2014-06-08 Thread arun
Hi, If you have library(qdap) installed: library(qdap) as.vector(bracketXtract(nw.str,"square",with=T)) #[1] "[D]" "[A|D]"   "[T|A:D]" "[C|T]"  A.K. On Sunday, June 8, 2014 4:31 PM, Alexsandro Cândido de Oliveira Silva wrote: Hi, I have a string something like that: nw.str <- "[D][A|D

Re: [R] Split a string vector with '[ ]'

2014-06-08 Thread David Winsemius
On Jun 8, 2014, at 1:46 PM, Duncan Murdoch wrote: > On 08/06/2014, 4:30 PM, Alexsandro Cândido de Oliveira Silva wrote: >> Hi, >> >> I have a string something like that: >> >> nw.str <- "[D][A|D][T|A:D][C|T]" >> >> And I need to split it in this way: >> >> "[D]" "[A|D]" "[T|A:D]" "[C|T]" > >

Re: [R] Split a string vector with '[ ]'

2014-06-08 Thread Duncan Murdoch
On 08/06/2014, 4:30 PM, Alexsandro Cândido de Oliveira Silva wrote: > Hi, > > I have a string something like that: > > nw.str <- "[D][A|D][T|A:D][C|T]" > > And I need to split it in this way: > > "[D]" "[A|D]" "[T|A:D]" "[C|T]" You could probably use lookahead and lookbehind Perl regular expre

Re: [R] Split a string vector with '[ ]'

2014-06-08 Thread jim holtman
try this: > nw.str <- "[D][A|D][T|A:D][C|T]" > x <- strsplit(nw.str, "]") > paste0(x[[1]], ']') [1] "[D]" "[A|D]" "[T|A:D]" "[C|T]" Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sun, Jun 8, 2014

[R] Split a string vector with '[ ]'

2014-06-08 Thread Alexsandro Cândido de Oliveira Silva
Hi, I have a string something like that: nw.str <- "[D][A|D][T|A:D][C|T]" And I need to split it in this way: "[D]" "[A|D]" "[T|A:D]" "[C|T]" Thanks!! Regards. Alexsandro Cândido __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/li