Skip to content
Prev 305789 / 398506 Next

Simple String Operation.

HI,
This may also work:
gsub("@\\S+\\s*","",x)
#[1] "Even in the mid-west spring is hardly for 3 weeks, while the scenario is different."
#or
gsub("@\\w+\\s*","",x)
#[1] "Even in the mid-west spring is hardly for 3 weeks, while the scenario is different."

A.K.

----- Original Message -----
From: David Winsemius <dwinsemius at comcast.net>
To: Bhupendrasinh Thakre <vickythakre at gmail.com>
Cc: r-help at r-project.org
Sent: Tuesday, September 18, 2012 12:58 PM
Subject: Re: [R] Simple String Operation.
On Sep 18, 2012, at 9:35 AM, Bhupendrasinh Thakre wrote:

            
If you do not know how to use dput then just show some code that creates the object of interest:
[1] "Even in the mid-west spring is hardly for 3 weeks, while the scenario is different."

I was puzzled that the documentation suggested this should work, but it only removed the first letter in the word.
[1] "Even in the mid-west spring is hardly for 3 weeks, while outh the scenario is different."

And this is how you use dput()
"Even in the mid-west spring is hardly for 3 weeks, while @south the scenario is different."

Notice that the output of dput on a character vector is not very revealing. It is sometimes useful to use this method to shorten a long object:

dput(head(x))
David Winsemius, MD
Alameda, CA, USA

______________________________________________
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.