这是一个简单的问题,但我看不到我做错了什么.
我在R工作,加入号码如变量a
我在R工作,加入号码如变量a
>a <- c("NM_020506.1","NM_020519.1","NM_001030297.2","NM_010281.2","NM_011419.3","NM_053155.2")
要从bioart包中获取信息,我需要在登录号后删除.1等.我通常用这段代码:
> b <- sub("..*","",a) >[1] "" "" "" "" "" ""
但是,您可以看到,这不是这个变量的正确方法.谁能帮我这个?
你只需要逃避这个时期:
原文链接:https://www.f2er.com/regex/357179.htmla <- c("NM_020506.1","NM_053155.2") gsub("\\..*",a) [1] "NM_020506" "NM_020519" "NM_001030297" "NM_010281" "NM_011419" "NM_053155"