Remove special characters from data frame

前端 未结 1 1900
野趣味
野趣味 2020-12-30 08:40

I have a matrix that contains the string \"Energy per �m\". Before the \'m\' is a diamond shaped symbol with a question mark in it - I don\'t know what it is.

I ha

相关标签:
1条回答
  • 2020-12-30 09:35

    There is probably a better way to do this than with regex (e.g. by changing the Encoding).

    But here is your regex solution:

    gsub("[^0-9A-Za-z///' ]", "", a)
    [1] "Energy per m"
    

    But, as pointed out by @JoshuaUlrich, you're better off to use:

    gsub("[^[:alnum:]///' ]", "", x)
    [1] "Energy per m"
    
    0 讨论(0)
提交回复
热议问题