An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121213/1b958625/attachment.pl>
changing character strings with hash marks
4 messages · simona mancini, Bert Gunter, arun +1 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121213/6a90498b/attachment.pl>
Hi,
You could also use:
gsub("\\w","#","Mary plays football")
#[1] "#### ##### ########"
#or
gsub("[A-Za-z]", "#", "Mary plays football")
A.K.
----- Original Message -----
From: Uwe Ligges <ligges at statistik.tu-dortmund.de>
To: simona mancini <mancinisimona at yahoo.it>
Cc: "r-help at r-project.org" <r-help at r-project.org>
Sent: Thursday, December 13, 2012 5:38 PM
Subject: Re: [R] changing character strings with hash marks
On 13.12.2012 22:30, simona mancini wrote:
Hi R users, I am quite new to R and I don't know how to deal with this (surely) easy issue. I need to replace words in sentences with as many hash marks as the number of characters per each word, as in the following example: Mary plays football #### ##### ########
gsub("[[:alpha:]]", "#", "Mary plays football")
Uwe Ligges
Any suggestion about the function to be used? Thanks a lot. S. ??? [[alternative HTML version deleted]]
______________________________________________ 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.
On 13.12.2012 22:30, simona mancini wrote:
Hi R users, I am quite new to R and I don't know how to deal with this (surely) easy issue. I need to replace words in sentences with as many hash marks as the number of characters per each word, as in the following example: Mary plays football #### ##### ########
gsub("[[:alpha:]]", "#", "Mary plays football")
Uwe Ligges
Any suggestion about the function to be used? Thanks a lot. S. [[alternative HTML version deleted]]
______________________________________________ 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.