Re: [R] trim a string

From: Mike R <mike.rstat_at_gmail.com>
Date: Sat 18 Jun 2005 - 04:53:40 EST

> How to trim the leading and trailing white space off of a string?
>
> If the variable is " E " I need to convert it to "E".

gsub('^[[:space:]]+', '', "   E     ")
gsub('[[:space:]]+$', '', "   E     ")

as in R-2.1.0/library/base/html/grep.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 18 05:03:34 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:49 EST