[R] Trim function ?

Ernesto Jardim ernesto at ipimar.pt
Thu May 9 19:29:05 CEST 2002


Hi

Do this means that we'll be able to use perl inside R ? If so, is it on
the source code or we have to have perl on the system ?

Regards

EJ

On Thu, 2002-05-09 at 17:09, ripley at stats.ox.ac.uk wrote:
> On 9 May 2002, Douglas Bates wrote:
> 
> > Ernesto Jardim <ernesto at ipimar.pt> writes:
> >
> > > Hi
> > >
> > > I've imported some data from a oracle database and the strings have a
> > > lot of blank space (because of the delimiter). I want to remove these
> > > blanks space with something similar to a trim function.
> > >
> > > I don't find a trim function or something similar. Can someone give a
> > > help on this ?
> >
> > If you want to remove trailing blanks you can use sub with the regular
> > expression ' +$'.
> >
> > > str = 'Now is the time      '
> > > sub(' +$', '', str, extended = TRUE)
> > [1] "Now is the time"
> >
> > I had hoped you could use '\s+$' or '\\s+$' but that doesn't seem to
> > work.  I guess we would need the perl regular expression library, of
> > which there has been some discussion, to do that.
> 
> In today's R-devel
> > sub('\\s+$', '', str, perl = TRUE)
> [1] "Now is the time"
> 
> but as it was literally added a few hours ago, don't expect it to have
> bedded down yet.  (I have support under Windows, but no connectivity to
> commit it at present.)
> 
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272860 (secr)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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