Use gsub remove all string before first numeric character

前端 未结 2 1543
小鲜肉
小鲜肉 2021-01-12 17:06

Use gsub remove all string before first white space in R

In this example, we try to remove everything before a space with sub(\".*? (.+)\", \"\\\\1\", D$name)<

2条回答
  •  太阳男子
    2021-01-12 17:24

    In R 3.6 (currently the R devel version) onwards trimws has a new whitespace argument which can be used to specify what is regarded as whitespace -- in this case any non-digit character:

    trimws(x, "left", "\\D")
    ## [1] "65lolo"    "3hihi"     "365meumeu"
    

提交回复
热议问题