Hi there I am trying to remove the white space and replace it with nothing but didnt have any luck with that x <- and fgh- i can replace the comma using gsub gsub("\\-","",x) but i cant replace the white space with nothing. Ramya -- View this message in context: http://old.nabble.com/Removing-white-space-help-tp26503431p26503431.html Sent from the R help mailing list archive at Nabble.com.
Is this what you want:> x <- " and fgh- " > gsub(" +", "", x)[1] "andfgh-" On Tue, Nov 24, 2009 at 4:18 PM, Ramyathulasingam <Ramya.Thulasingam at rndsystems.com> wrote:> > Hi ?there > > I am trying to remove the white space and replace it with nothing but didnt > have any luck with that > > x <- and fgh- > > i can replace the comma using gsub > gsub("\\-","",x) > but i cant replace the white space with nothing. > > Ramya > -- > View this message in context: http://old.nabble.com/Removing-white-space-help-tp26503431p26503431.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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?
If I understand, you can try this: gsub("\\s+","",x) On Tue, Nov 24, 2009 at 7:18 PM, Ramyathulasingam <Ramya.Thulasingam at rndsystems.com> wrote:> > Hi ?there > > I am trying to remove the white space and replace it with nothing but didnt > have any luck with that > > x <- and fgh- > > i can replace the comma using gsub > gsub("\\-","",x) > but i cant replace the white space with nothing. > > Ramya > -- > View this message in context: http://old.nabble.com/Removing-white-space-help-tp26503431p26503431.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O