Re: [R] String replacement in an expression

2009-05-28 Thread Wacek Kusnierczyk
: Thursday, May 28, 2009 12:31 PM >> To: Caroline Bazzoli >> Cc: r-help@r-project.org >> Subject: Re: [R] String replacement in an expression >> >> Caroline Bazzoli wrote: >> >>> Dear R-experts, >>> >>> I need to replace in an express

Re: [R] String replacement in an expression

2009-05-28 Thread William Dunlap
> Cc: r-help@r-project.org > Subject: Re: [R] String replacement in an expression > > Caroline Bazzoli wrote: > > Dear R-experts, > > > > I need to replace in an expression the character "Cl" by "Cl+beta" > > > > But in the following

Re: [R] String replacement in an expression

2009-05-28 Thread Wacek Kusnierczyk
Caroline Bazzoli wrote: > Dear R-experts, > > I need to replace in an expression the character "Cl" by "Cl+beta" > > But in the following case: > > form<-expression((Cl-(V *ka) ) +(V *Vm *exp(-(Clm/Vm) *t))) > > gsub("Cl","(Cl+beta)",as.character(form)) > > We obtain: > > [1] "((Cl+beta) - (

Re: [R] String replacement in an expression

2009-05-28 Thread William Dunlap
> From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Caroline Bazzoli > Sent: Thursday, May 28, 2009 8:41 AM > To: r-help@r-project.org > Subject: [R] String replacement in an expression > > Dear R-experts, > > I need to replace in an expression the character

Re: [R] String replacement in an expression

2009-05-28 Thread Gabor Grothendieck
Try matching on word boundaries as well: > gsub("\\bCl\\b","(Cl+beta)",as.character(form)) [1] "((Cl+beta) - (V * ka)) + (V * Vm * exp(-(Clm/Vm) * t))" See ?regexp On Thu, May 28, 2009 at 11:41 AM, Caroline Bazzoli wrote: > Dear R-experts, > > I need to replace in an expression the character "C