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 <lig...@statistik.tu-dortmund.de> To: simona mancini <mancinisim...@yahoo.it> Cc: "r-help@r-project.org" <r-help@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@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@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@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.