Remove part of a string

前端 未结 6 1807
执笔经年
执笔经年 2020-11-27 11:07

How do I remove part of a string? For example in ATGAS_1121 I want to remove everything before _.

6条回答
  •  一整个雨季
    2020-11-27 11:38

    Here's the strsplit solution if s is a vector:

    > s <- c("TGAS_1121", "MGAS_1432")
    > s1 <- sapply(strsplit(s, split='_', fixed=TRUE), function(x) (x[2]))
    > s1
    [1] "1121" "1432"
    

提交回复
热议问题