Re: [R] remove last char of a text string

From: Sarah Goslee <>
Date: Mon, 14 Jun 2010 09:52:24 -0400

Sure. You can use nchar() to find out how long the string is.

> teststring <- "01asap05a"
> substr(teststring, 1, nchar(teststring)-1)
[1] "01asap05"

On Mon, Jun 14, 2010 at 9:47 AM, glaporta <> wrote:
> Dear R experts,
> is there a simple way to remove the last char of a text string?
> substr() function use as parameter start end only... but my strings are of
> different length...
> 01asap05a -> 01asap05
> 02ee04b -> 02ee04
> Thank you all,
> Gianandrea

Sarah Goslee

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 14 Jun 2010 - 13:54:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jun 2010 - 14:00:29 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive