[R] Help with replacing a substring in a string

Nikhil Kaza nikhil.list at gmail.com
Mon Jul 19 15:14:18 CEST 2010


gsub(".", " ", "abc.degg.hijk", fixed=T)

On Jul 19, 2010, at 7:37 AM, Tolga I Uzuner wrote:

> Actually, I think I got it, need to use gsub.
> From: Tolga I Uzuner
> Sent: 19 July 2010 12:11
> To: 'r-help at r-project.org'
> Subject: Help with replacing a substring in a string
>
> Dear R Users,
>
> I am trying to replace a substring in a string with something else.
>
> For example:
> if we have "abc.degg.hijk"
> I would like to replace all the "." with a SPACE to become
> "abc degg hijk"
>
> I have tried the replace.substring.wild function in the Hmisc  
> package but get this error:
>
>> replace.substring.wild("abc.degg.hijk","*.*"," ")
> Error in replace.substring.wild("abc.degg.hijk", "*.*", " ") :
>  does not handle > 1 * in old
>>
>
> Can't really figure out from the function description or the error  
> message what I am doing wrong.
>
> Any assistance would be appreciated, thanks in advance.
>
> Regards,
> Tolga
>
>
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of
> securities, accuracy and completeness of information, viruses,
> confidentiality, legal privilege, and legal entity disclaimers,
> available at http://www.jpmorgan.com/pages/disclosures/email.
> 	[[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.



More information about the R-help mailing list