Is there an specific function to eliminate blank space within strings? Thanks -- Dr. Agustin Lobo Institut de Ciencies de la Terra "Jaume Almera" (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: Agustin.Lobo at ija.csic.es http://www.ija.csic.es/gt/obster
Romain Francois
2009-Jul-03 10:46 UTC
[R] Function to eliminate blank space within strings?
On 07/03/2009 10:34 AM, Agustin Lobo wrote:> > Is there an specific function > to eliminate blank space within > strings? > Thanksgsub( "[[:space:]]+", "", string ) -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/qJ8V : RGG#153: stars network |- http://tr.im/qzSl : using ImageJ from R: the RImageJ package `- http://tr.im/qzSJ : with semantics for java objects in rJava
Duncan Murdoch
2009-Jul-03 10:54 UTC
[R] Function to eliminate blank space within strings?
Agustin Lobo wrote:> Is there an specific function > to eliminate blank space within > strings? >No, but gsub could do that. Duncan Murdoch
How much blank space do you want to remove? all to one, all to none, leading, trailing? You can use regular expressions:> x <- " my test string " > # leading > sub("^ +", "", x)[1] "my test string "> # trailing > sub(" +$", '', x)[1] " my test string"> # multiple to one > gsub(" +", " ", x)[1] " my test string ">On Fri, Jul 3, 2009 at 4:34 AM, Agustin Lobo<aloboaleu at gmail.com> wrote:> Is there an specific function > to eliminate blank space within > strings? > Thanks > -- > Dr. Agustin Lobo > Institut de Ciencies de la Terra "Jaume Almera" (CSIC) > LLuis Sole Sabaris s/n > 08028 Barcelona > Spain > Tel. 34 934095410 > Fax. 34 934110012 > email: Agustin.Lobo at ija.csic.es > http://www.ija.csic.es/gt/obster > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?