首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在单词之前删除字符串中的字符(以R为单位)

在单词之前删除字符串中的字符(以R为单位)
EN

Stack Overflow用户
提问于 2017-10-24 08:58:25
回答 3查看 469关注 0票数 2

我是这个社区的新手,我想问这个问题(我没有发现任何问题可以帮助我)。

我有一根绳子:

代码语言:javascript
复制
{name:GTP hydrolysis and joining of the 60S ribosomal subunit,description:Hydrolysis of eIF2-GTP occurs after the Met-tRNAi has recognized the AUG. This reaction is catalyzed by eIF5 (or eIF5B) and is thought to cause dissociation of all other initiation factors and allow joining of the large 60S ribosomal subunit. The 60S subunit joins - a reaction catalyzed by eIF5 or eIF5B - resulting in a translation-competent 80S ribosome. Following 60S subunit joining, eIF5B hydrolyzes its GTP and is released from the 80S ribosome, which is now ready to start elongating the polypeptide chain.,url:https://reactome.org/PathwayBrowser/#/R-HSA-72706,sameAs:null,version:62,keywords:[Pathway],creator:[],includedInDataCatalog:{url:https://reactome.org,name:Reactome,@type:DataCatalog},distribution:[{contentUrl:https://reactome.org/ContentService/exporter/sbml/72706.xml,fileFormat:SBML,@type:DataDownload},{contentUrl:https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/sbgnExporter/72706,fileFor... <truncated>

这是非常混乱的,我想删除所有字符之前的文字描述。结果会是这样:

代码语言:javascript
复制
description:Hydrolysis of eIF2-GTP occurs after the Met-tRNAi has recognized the AUG. This reaction is catalyzed by eIF5 (or eIF5B) and is thought to cause dissociation of all other initiation factors and allow joining of the large 60S ribosomal subunit. The 60S subunit joins - a reaction catalyzed by eIF5 or eIF5B - resulting in a translation-competent 80S ribosome. Following 60S subunit joining, eIF5B hydrolyzes its GTP and is released from the 80S ribosome, which is now ready to start elongating the polypeptide chain.,url:https://reactome.org/PathwayBrowser/#/R-HSA-72706,sameAs:null,version:62,keywords:[Pathway],creator:[],includedInDataCatalog:{url:https://reactome.org,name:Reactome,@type:DataCatalog},distribution:[{contentUrl:https://reactome.org/ContentService/exporter/sbml/72706.xml,fileFormat:SBML,@type:DataDownload},{contentUrl:https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/sbgnExporter/72706,fileFor... <truncated>

提前感谢!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-10-24 09:07:55

您应该使用reg ex方法,这样您就可以处理不同数量的主角:

代码语言:javascript
复制
a <- "{name:GTP hydrolysis and joining of the 60S ribosomal subunit,description:Hydrolysis of eIF2-GTP occurs after the Met-tRNAi has recognized the AUG. This reaction is catalyzed by eIF5 (or eIF5B) and is thought to cause dissociation of all other initiation factors and allow joining of the large 60S ribosomal subunit. The 60S subunit joins - a reaction catalyzed by eIF5 or eIF5B - resulting in a translation-competent 80S ribosome. Following 60S subunit joining, eIF5B hydrolyzes its GTP and is released from the 80S ribosome, which is now ready to start elongating the polypeptide chain.,url:https://reactome.org/PathwayBrowser/#/R-HSA-72706,sameAs:null,version:62,keywords:[Pathway],creator:[],includedInDataCatalog:{url:https://reactome.org,name:Reactome,@type:DataCatalog},distribution:[{contentUrl:https://reactome.org/ContentService/exporter/sbml/72706.xml,fileFormat:SBML,@type:DataDownload},{contentUrl:https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/sbgnExporter/72706,fileFor..."

gsub('(.*)description:','', a)
票数 4
EN

Stack Overflow用户

发布于 2017-10-24 09:10:06

您可以使用来自str_extractstringr

代码语言:javascript
复制
library(stringr)
str_extract(text, "description:(?s)(.*$)")

"description:Hydrolysis of eIF2-GTP occurs after the ...
票数 3
EN

Stack Overflow用户

发布于 2017-10-24 09:06:30

这个怎么样?

代码语言:javascript
复制
library(stringr)
yourData$yourColumn <- str_sub(yourData$yourColumn, start=62)  # hope I've counted right!
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46906190

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档