R removes special characters from the data frame

I have a matrix containing the string "Energy per m". Before “m” is a diamond-shaped symbol with a question mark in it, I do not know what it is.

I tried to get rid of it using this in the matrix column:

a=gsub('Energy per  m','',a) 

[and using copy / paste for the first gsub member], but it does not work. [unexpected character in "a = rep (5, Energy per"). When I try to extract something from the original matrix using grepl, I get:

46: In grepl("ref. value", raw$parameter) :
input string 15318 is invalid in this locale

How can I get rid of all these symptoms? I would like to have only 0-9, AZ, az, / and '. The rest can be blocked.

+5
source share
1 answer

, , (, Encoding).

:

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

, @JoshuaUlrich, :

gsub("[^[:alnum:]///' ]", "", x)
[1] "Energy per m"
+18

All Articles