Extract a string between patterns/delimiters in R

前端 未结 4 2005
借酒劲吻你
借酒劲吻你 2020-12-11 22:24

I have variable names in the form:

PP_Sample_12.GT

or

PP_Sample-17.GT

I\'m trying to use string split to

4条回答
  •  情歌与酒
    2020-12-11 22:38

    Here's a gsub that will extract everything after the first _ and before the last .

    x<-c("PP_Sample-12.GT","PP_Sample-17.GT")
    gsub(".*_(.*)\\..*","\\1", x, perl=T)
    

提交回复
热议问题