[R] removing blanks from a string
john seers (IFR)
john.seers at bbsrc.ac.uk
Fri Jun 27 11:37:31 CEST 2008
There is also the "trim" command in the gdata package. Removes blanks
from the front of the string as well which may not be what you want.
Regards
JS
---
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of jim holtman
Sent: 27 June 2008 10:27
To: juli pausas
Cc: R-help
Subject: Re: [R] removing blanks from a string
Is this what you want:
> x <- c("hola ", "Yes ", "hello ")
> gsub(" *$", "", x)
[1] "hola" "Yes" "hello"
>
>
On Fri, Jun 27, 2008 at 4:34 AM, juli pausas <pausas at gmail.com> wrote:
> Hi
> Is there a way to remove blank characters from the end of strings in a
> vector? Something like the =TRIM functions of the OpenOffice
> spreadsheet. E.g.,
> a <- c("hola ", "Yes ", "hello ") # I'd like to get:
> c("hola", "Yes", "hello")
>
> Thanks
>
> Juli
>
>
> --
> http://www.ceam.es/pausas
>
> ______________________________________________
> 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 you are trying to solve?
______________________________________________
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