Skip to content
Prev 366116 / 398502 Next

Need some help with regular expression

I tried to send this email, but it didn't go through. I guess pictures are
not allowed to send through HTML formatted emails?
I'm re-sending it again without the picture, just comment there instead as
placeholder.

Thanks,
Steven


From: Steven Nagy [mailto:nstefi at gmail.com] 
Sent: Monday, December 12, 2016 10:50 PM
To: 'Bert Gunter' <bgunter.4567 at gmail.com>
Cc: 'R-help' <r-help at r-project.org>
Subject: RE: [R] Need some help with regular expression

Hi Bert and all,

Sorry I was too busy at work and didn't have much time to continue this
until now.
So I studied "?regexp" and I can understand your regular expression now:
sub(".*: *([[:alnum:]]* *-> *STU|STU *-> *[[:alnum:]]*).*","\\1",x)

But I also wanted to split up these results in 2 columns, so your previous
command would give me this result:
[1] "NMA -> STU" "STU -> REG" "-> STU"

and I wanted to further split them up to show this:
From	To
NMA	STU
STU	REG
	STU

I still don?t quite understand the backreferences, and how could I have 2
backreferences, one for the left side of the ?->? sign and one for the right
side?

So it seems like I need to apply the ?sub? function twice, similar how I
used the ?strapply? function twice in my original post:
strapply(strapply(a, "(file://w+ -> STU|STU -> file://w+)", c, backref = -1,
perl = TRUE), "(file://w+) -> (file://w+)", c, backref = -2, perl = TRUE)

or maybe there would be a more simple way of using only 1 ?sub? function and
2 backreferences?

Also I?m not sure what do I do after I get the data? How could I represent
the member type changes graphically? We need to analyze the behavior of
switching from STU to another type or from another type to STU.
Google Analytics has a nice chart under Behavior Flow, or Users Flow, and it
looks like this:
<here was my picture from Google Analytics - it's from Behavior Flow or
Users Flow showing flows from one category to another one and further to
another one>



Is there any graphical representation in R that is similar to this?

Thanks a lot,
Steven

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Bert Gunter
Sent: Sunday, November 20, 2016 10:05 PM
To: Aliz Csonka <mailto:lyzae.ro at gmail.com>
Cc: R-help <mailto:r-help at r-project.org>
Subject: Re: [R] Need some help with regular expression

Although others may respond, I think you will do much better studying
?regexp, which will answer all your questions. I believe the effort you will
make figuring it out will pay dividends for your future R/regular expression
usage that you cannot gain from my direct explanation.

Good luck.

Best,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Nov 20, 2016 at 6:40 PM, Steven Nagy <mailto:nstefi at gmail.com>
wrote:
wrote:
-1,
-1,
=
______________________________________________
mailto:R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.