[R] Trimming blanks from the ends of strings
Ross Ihaka
ihaka at stat.auckland.ac.nz
Fri Jun 1 03:15:37 CEST 2001
s-luppescu at uchicago.edu wrote:
>
> This is pretty mundane, but I much appreciate the help. I have character
> variables that I have read in from 40-character-wide fields. I want to remove
> the spaces from the ends so I can use them right justified (adj=1) as labels on
> the vertical axis of a graph.
Something like
sub("^ *", "", sub(" *$", "", x))
should do the trick. E.g.
> sub("^ *", "", sub(" *$", "", " padded "))
[1] "padded"
--
Ross Ihaka Email: ihaka at stat.auckland.ac.nz
Department of Statistics Phone: (64-9) 373-7599 x 5054
University of Auckland Fax: (64-9) 373-7018
Private Bag 92019, Auckland
New Zealand
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list