Simona:

If you intend to work with text, you need to learn about regular
expressions. There are many tutorials on this topic on the web. Go search.

Then learn about how R handles them via:
?regex  ## at the R prompt

Then ask your question more clearly, although by this time you'll probably
have figured it out yourself: For example, you failed to specify whether
punctuation could appear in the sentences or what language (and character
set) is used.

Finally, an answer (there are others) to the question you posed -- which is
probably not going to be sufficient -- is:

> gsub("[^ ]","#","Mary plays football")
[1] "#### ##### ########"

Cheers,
Bert

On Thu, Dec 13, 2012 at 1:30 PM, simona mancini <mancinisimona@yahoo.it>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
> #### ##### ########
>
> 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.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

	[[alternative HTML version deleted]]


