Re: [R] Substring replacement in string

2015-03-01 Thread Hervé Pagès
, H. Best wishes, Alrik -Ursprüngliche Nachricht- Von: Hervé Pagès [mailto:hpa...@fredhutch.org] Gesendet: Samstag, 28. Februar 2015 23:29 An: Alrik Thiem; r-help@r-project.org Betreff: Re: [R] Substring replacement in string Hi Alrik, With the Biostrings/IRanges infrastructure

Re: [R] Substring replacement in string

2015-02-28 Thread Gabor Grothendieck
On Fri, Feb 27, 2015 at 5:19 PM, Alrik Thiem alrik.th...@gmail.com wrote: I would like to replace all lower-case letters in a string that are not part of certain fixed expressions. For example, I have the string: pmin(pmax(pmin(x1, X2), pmin(X3, X4)) == Y, pmax(Z1, z1)) Where I would like to

Re: [R] Substring replacement in string

2015-02-28 Thread Alrik Thiem
...@aghmed.fsnet.co.uk] Gesendet: Samstag, 28. Februar 2015 14:50 An: Alrik Thiem Cc: r-help@r-project.org Betreff: Re: [R] Substring replacement in string Dear Alrik This may seem a silly suggestion but why not just define new functions PMIN and PMAX to call pmin and pmax. Obviously that does

Re: [R] Substring replacement in string

2015-02-28 Thread William Dunlap
: [R] Substring replacement in string If your string will always represent an R expression, you could work with the expression directly with functions like all.names() and substitute(). f - function (expr) { toReplace - setdiff(all.names(expr), c(pmin, pmax)) toReplace - grep

Re: [R] Substring replacement in string

2015-02-28 Thread Hervé Pagès
Hi Alrik, With the Biostrings/IRanges infrastructure (Bioconductor packages), you can do this with: library(Biostrings) x0 - BString(pmin(pmax(pmin(x1, X2), pmin(X3, X4)) == Y, pmax(Z1, z1))) donttouch_words - c(pmin, pmax) ## Extract the substrings to modify (target substrings).

Re: [R] Substring replacement in string

2015-02-28 Thread Alrik Thiem
-Ursprüngliche Nachricht- Von: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Gesendet: Samstag, 28. Februar 2015 13:35 An: Alrik Thiem Cc: r-help@r-project.org Betreff: Re: [R] Substring replacement in string On Fri, Feb 27, 2015 at 5:19 PM, Alrik Thiem alrik.th...@gmail.com wrote: I

Re: [R] Substring replacement in string

2015-02-28 Thread Michael Dewey
Grothendieck [mailto:ggrothendi...@gmail.com] Gesendet: Samstag, 28. Februar 2015 13:35 An: Alrik Thiem Cc: r-help@r-project.org Betreff: Re: [R] Substring replacement in string On Fri, Feb 27, 2015 at 5:19 PM, Alrik Thiem alrik.th...@gmail.com wrote: I would like to replace all lower-case letters

Re: [R] Substring replacement in string

2015-02-28 Thread Alrik Thiem
Ah, I see what you mean. Thanks for suggesting. I'll try. -Ursprüngliche Nachricht- Von: Michael Dewey [mailto:i...@aghmed.fsnet.co.uk] Gesendet: Samstag, 28. Februar 2015 17:31 An: Alrik Thiem Cc: r-help@r-project.org Betreff: Re: AW: [R] Substring replacement in string Your original

Re: [R] Substring replacement in string

2015-02-28 Thread Alrik Thiem
Dear Gabor, That works perfectly! Many thanks and best wishes, Alrik -Ursprüngliche Nachricht- Von: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Gesendet: Samstag, 28. Februar 2015 19:30 An: Alrik Thiem Cc: r-help@r-project.org Betreff: Re: [R] Substring replacement in string

Re: [R] Substring replacement in string

2015-02-28 Thread Michael Dewey
...@aghmed.fsnet.co.uk] Gesendet: Samstag, 28. Februar 2015 14:50 An: Alrik Thiem Cc: r-help@r-project.org Betreff: Re: [R] Substring replacement in string Dear Alrik This may seem a silly suggestion but why not just define new functions PMIN and PMAX to call pmin and pmax. Obviously that does not solve your problem

Re: [R] Substring replacement in string

2015-02-28 Thread Gabor Grothendieck
: r-help@r-project.org Betreff: Re: [R] Substring replacement in string On Fri, Feb 27, 2015 at 5:19 PM, Alrik Thiem alrik.th...@gmail.com wrote: I would like to replace all lower-case letters in a string that are not part of certain fixed expressions. For example, I have the string: pmin

Re: [R] Substring replacement in string

2015-02-28 Thread Alrik Thiem
[mailto:hpa...@fredhutch.org] Gesendet: Samstag, 28. Februar 2015 23:29 An: Alrik Thiem; r-help@r-project.org Betreff: Re: [R] Substring replacement in string Hi Alrik, With the Biostrings/IRanges infrastructure (Bioconductor packages), you can do this with: library(Biostrings) x0 - BString

Re: [R] Substring replacement in string

2015-02-27 Thread Alrik Thiem
Thiem Cc: r-help@r-project.org Betreff: Re: [R] Substring replacement in string If your string will always represent an R expression, you could work with the expression directly with functions like all.names() and substitute(). f - function (expr) { toReplace - setdiff(all.names(expr), c

Re: [R] Substring replacement in string

2015-02-27 Thread William Dunlap
If your string will always represent an R expression, you could work with the expression directly with functions like all.names() and substitute(). f - function (expr) { toReplace - setdiff(all.names(expr), c(pmin, pmax)) toReplace - grep(value = TRUE, [a-z], toReplace)

[R] Substring replacement in string

2015-02-27 Thread Alrik Thiem
Dear R-help list, I would like to replace all lower-case letters in a string that are not part of certain fixed expressions. For example, I have the string: pmin(pmax(pmin(x1, X2), pmin(X3, X4)) == Y, pmax(Z1, z1)) Where I would like to replace all lower-case letters that do not belong to the