Re: [R] replace last 3 characters of string

2011-04-04 Thread Dieter Menne
Bert Jacobs-2 wrote: > > I would like to replace the last tree characters of the values of a > certain > column in a dataframe. > > Besides the mentioned standard method: I found the subset of string operations in Hadley Wickhams stringr package helpful. They have a much more consistent interf

Re: [R] replace last 3 characters of string

2011-04-03 Thread jim holtman
Will this do it for you: > x <- c('asdfasdf', 'sadfasdf/:/', 'sadf', 'asdf/:/') > sub("/:/$", '', x) [1] "asdfasdf" "sadfasdf" "sadf" "asdf" On Sun, Apr 3, 2011 at 7:39 PM, Bert Jacobs wrote: > Hi, > > > > I would like to replace the last tree characters of the values of a certain > column i

Re: [R] replace last 3 characters of string

2011-04-03 Thread Bert Jacobs
Thx I could imagine it was so simple.:) Bert -Original Message- From: Dirk Eddelbuettel [mailto:e...@master.debian.org] On Behalf Of Dirk Eddelbuettel Sent: 04 April 2011 01:39 To: Bert Jacobs Cc: r-help@r-project.org Subject: Re: [R] replace last 3 characters of string On Mon, Apr 04

Re: [R] replace last 3 characters of string

2011-04-03 Thread Dirk Eddelbuettel
On Mon, Apr 04, 2011 at 01:39:34AM +0200, Bert Jacobs wrote: > I would like to replace the last tree characters of the values of a certain > column in a dataframe. > > This replacement should only take place if the last three characters > correspond to the value "/:/" and they should be replaced w

[R] replace last 3 characters of string

2011-04-03 Thread Bert Jacobs
Hi, I would like to replace the last tree characters of the values of a certain column in a dataframe. This replacement should only take place if the last three characters correspond to the value "/:/" and they should be replaced with ""(blank) I cannot perform a simple gsub because the chara