<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-07 18:49 GMT-03:00 Waldelene Moura <span dir="ltr"><<a href="mailto:waldelene@yahoo.com.br" target="_blank">waldelene@yahoo.com.br</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div style="font-size:10pt;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif">
<div><span>Olá </span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><span><br>
</span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><span>Sou iniciante no R, preciso retirar de uma string um caractere <span style="font-weight:bold">específico</span> que esteja <span style="font-weight:bold">repetido,  </span>trocando estes por apenas <span style="font-weight:bold">um</span>,</span></div>
<div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><span><br></span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif">
<span>Ex: a = "23345556333388"     gostaria de retirar o 3 especificamente que estão repetidos, logo a string ficaria</span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif">
<span>      a = "2345556388"         -  só altero onde o 3 aparece, os outros continuam como estão.</span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif">
<span><br></span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><span><br>
</span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><span>outro exemplo</span></div>
<div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><span>      texto = "BOLLA  CARRO  LLATA  CASSINO "  
 aplicando somente para a letra L</span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif">
<span>      texto = "BOLA CARRO LATA  CASSINO"</span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif">
<span><br></span></div><div style="font-style:normal;font-size:13.63636302947998px;background-color:transparent;font-family:HelveticaNeue,'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif"><span>Alguém poderia me dar uma dica de qual função usar?</span></div>
</div></div></blockquote><div><br></div><div><br></div><div><div>gsub("33*", "3", a)</div><div>gsub("LL*", "L", gsub("  *", " ", texto))</div></div><div><br></div>
<div>No "texto", você também eliminou quase todos os espaços duplicados. Por isso, o exemplo acima inclui um gsub() para eliminar excesso de espaço em branco.</div></div></div></div>