Re: [R] How to replace 'star (*)' with blank space?

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Wed, 20 Apr 2011 13:08:46 +0200

gsub("\\*", " ",x)

should do. Please read about regular expression as used by gsub().

Uwe Ligges

On 20.04.2011 12:00, Ruby Chu wrote:
> Hi There
>
> I'm not very sure how to replace the stars in a character vector
>
> For example:
>
> a character vector (n rows by 1 col)
>
> [1] "-27 -21 -25 -28**** ***** -29"
> [2] "-27 ******** -28**** ***** -29"
> .
> .
> .
> .
> .
> .
> [n] "-1***********************************"
>
> I wish to replace all the *s with a blank, result as per below
>
> [1] "-27 -21 -25 -28 -29"
> [2] "-27 -28 -29"
> .
> .
> .
> .
> .
> .
> [n] "-1 "
>
> I have tried to use gsub( )
> like: gsub("*", "", x)
> but doesn't seem to be working...please advise
>
> Thank you
>
> Ruby
>
> [[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. Received on Wed 20 Apr 2011 - 11:10:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Apr 2011 - 11:50:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive