Remove string from a vector in R

后端 未结 3 471
名媛妹妹
名媛妹妹 2020-12-22 02:26

I have a vector that looks like

> inecodes
   [1] \"01001\" \"01002\" \"01049\" \"01003\" \"01006\" \"01037\" \"01008\" \"01004\" \"01009\" \"01010\" \"01         


        
3条回答
  •  时光说笑
    2020-12-22 03:22

    library(stringr)
    
    for(code in inecodes) {
      ix <- which(str_detect(pob, code))
      pob[ix] <- unlist(str_split(pob, "-", 2))[2]
    }
    

提交回复
热议问题