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 Barradas <ruipbarra...@sapo.pt> wrote:

> 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 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
>>
>> ______________________________**________________
>> R-help@r-project.org  mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guidehttp://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________**________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to