我试图在对其进行操作之前清理文本数据,并且即使当我尝试使用gsub专门针对它时,符号也不会被删除,然后当我尝试小写时抛出错误。
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)
}
试试这个
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)
}