Re: [R] replacing a character string

2012-08-12 Thread David Winsemius
On Aug 10, 2012, at 7:18 AM, toehanus wrote: I am working on modifying a REDCap survey. The data dictionary column for the response field has the following value. 1, Strongly disagree | 2, Disagree | 3, Agree | 4, Strongly Agree | 5, Don't Know | 6, Refuse to Answer | 7, Not Applicable

Re: [R] replacing a character string

2012-08-12 Thread Rui Barradas
Hello, I believe I don't understand your problem. Is this your input datum? x <- "1, Strongly disagree | 2, Disagree | 3, Agree | 4, Strongly Agree | 5, Don't Know | 6, Refuse to Answer | 7, Not Applicable" If so the following will do it: (search <- paste("(", 1:7, ",)", sep = "")) (replace

[R] replacing a character string

2012-08-10 Thread toehanus
I am working on modifying a REDCap survey. The data dictionary column for the response field has the following value. 1, Strongly disagree | 2, Disagree | 3, Agree | 4, Strongly Agree | 5, Don't Know | 6, Refuse to Answer | 7, Not Applicable I am wanting to convert this so that it looks as follo

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=