Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't remove � symbols in R with regex

I am trying to clean text data before doing operations with it and the � symbol keeps not getting removed even when I try to target it specifically with gsub and then throwing an error when I try to lower cases.

normalize_name <- function(name){
  
  normalized_name <- gsub("[^[0-9A-Za-z][:blank:]]", "", name) #Removes special characters and spaces
  normalized_name <- gsub("�", "", normalized_name)
  normalized_name <- tolower(normalized_name)
  return(normalized_name)
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Try this

normalize_name <- function(name){
  
  normalized_name <- gsub("[^[0-9A-Za-z][:blank:]]", "", name) #Removes special characters and spaces
  normalized_name <- gsub("\UFFFD", "", normalized_name)
  normalized_name <- tolower(normalized_name)
  return(normalized_name)
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading