[R] re placePatterns() for multiple words replacement in tm
Kelvin Lam
lamkelf at gmail.com
Tue Aug 11 20:14:00 CEST 2009
Thanks. The replacePatterns() is from the text mining package tm().
Bert Gunter wrote:
>
> Don't use replacePatterns() (-- and what package is that from, btw??).
>
> gsub("abc|def","Yes",sample[[1]])
>
> Incidentally, "sample" is a rather bad name for your dataset, as it is the
> name of a commonly use R function. Ergo, possibility of confusion.
>
> Bert Gunter
> Genentech Nonclinical Biostatisics
>
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On
> Behalf Of Kelvin Lam
> Sent: Tuesday, August 11, 2009 9:43 AM
> To: r-help at r-project.org
> Subject: [R] re placePatterns() for multiple words replacement in tm
>
>
> Hi all,
>
> I wonder how you can replace all words that need to be changed using
> replacePatterns(). The following is my code. I want to replace both
> "abc"
> and "def" to " Yes ". However, I can only replace the first occurrence in
> sample[[1]].
>
>> sample[[1]]
> [1] abc def ghi
>> change <- c("abc","def")
>> replacePatterns(sample[[1]],change," Yes ")
> [1] Yes def ghi
>
> Thank you so much!!!!
>
> --
> View this message in context:
> http://www.nabble.com/replacePatterns%28%29-for-multiple-words-replacement-i
> n-tm-tp24921281p24921281.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>
> ______________________________________________
> 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.
>
>
--
View this message in context: http://www.nabble.com/replacePatterns%28%29-for-multiple-words-replacement-in-tm-tp24921281p24922958.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list