Re: [R] how to remove part of the string

2012-06-06 Thread Martin Schilling
Dear Bill, If you're not bound to gsub(), you could simply take substring() as follows: string <- "LTA4H||Leukotriene A4 hydrolase" substring(string, 1,5) This one works quite well and it could also be complemented with nchar() to "cut" strings with different lengths like substring(string, 1,

Re: [R] how to remove part of the string

2012-06-06 Thread andrija djurovic
Hi. Rui already gave you a solution. Beside that you can, also, use substr function in this concrete example: substr("LTA4H||Leukotriene A4 hydrolase", 1, 5) This can be adjusted to rest of your data also, but you haven't provided enough information. Andrija On Wed, Jun 6, 2012 at 11:27 PM, Rui

Re: [R] how to remove part of the string

2012-06-06 Thread Rui Barradas
Hello, Try txt <- "LTA4H||Leukotriene A4 hydrolase" pattern <- "\\|\\|.*$" gsub(pattern, "", txt) Hope this helps, Rui Barradas Em 06-06-2012 21:45, Bill Hyman escreveu: Dear all, Does any one know how to remove part of the string? For example, "LTA4H||Leukotriene A4 hydrolase" is a gene

Re: [R] how to remove part of the string

2012-06-06 Thread andrija djurovic
Hi. You can do something like this: gsub("\\|\\|Leukotriene A4 hydrolase","","LTA4H||Leukotriene A4 hydrolase") Andrija On Wed, Jun 6, 2012 at 10:45 PM, Bill Hyman wrote: > Dear all, > > Does any one know how to remove part of the string? > > For example, "LTA4H||Leukotriene A4 hydrolase" is a

[R] how to remove part of the string

2012-06-06 Thread Bill Hyman
Dear all, Does any one know how to remove part of the string? For example, "LTA4H||Leukotriene A4 hydrolase" is a gene name plus gene description. I hope to remove "||Leukotriene A4 hydrolase". What would be the R code to do that using gsub()? Many thanks! Bill ___