Re: [R] Replacing a character string when finding substring match

2008-02-14 Thread Henrique Dallazuanna
Try this: x[grep("vehicle", x, ignore=T)] <- "Vehicle" On 14/02/2008, Judith Flores <[EMAIL PROTECTED]> wrote: > Dear R-experts, > > I need to replace the values of a vector(tx) with a > word ('Vehicle') when the value of the vector contains > the word 'vehicle'. Sometimes, the value could be

[R] Replacing a character string when finding substring match

2008-02-14 Thread Judith Flores
Dear R-experts, I need to replace the values of a vector(tx) with a word ('Vehicle') when the value of the vector contains the word 'vehicle'. Sometimes, the value could be 'MCT vehicle', or 'control-vehicle', etc. I tried gsub like this treatment<-gsub('vehicle','Vehicle', tx, ignore.case=