代码之家  ›  专栏  ›  技术社区  ›  shy zhan

如何在最后一个字母的末尾拆分字符串?

  •  0
  • shy zhan  · 技术社区  · 7 年前

    提前谢谢你!

    1 回复  |  直到 7 年前
        1
  •  0
  •   cephalopod    7 年前

    如果只想提取最后一个字符,可以尝试使用以下策略 tidyverse

    library(tidyverse)
    
    x <- c("bananas1", "insurance?", "town!", "hostel 4", "qualifications 5", "labor-consuming 6", "problem solving 7")
    
    map2_chr(x, (str_length(x) ), ~str_sub(.x, .y, .y))
    
    推荐文章