Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

encode special characters in R

$
0
0

My dataset contains a lot of surnames. Those surnames are written with umlauts as well as other special characters (such as č,á,ñ, etc.).

By reading the data in the following way (using encoding = "latin1"), I managed to display the umlauts in a proper manner:

read_data <- function(directory,debug=FALSE){
  file_list = list.files(path = directory,
                       pattern = "*.csv",
                       full.names = TRUE);

  df_read = data.frame();

  for (filename in file_list){
    df_temp = read_delim(filename,
                      delim=';',
                      locale = locale(encoding = "latin1"));

    if(debug){
      print(paste0(c(filename, " : ", dim(df_temp))));  
    }

    df_read = rbind(df_read, df_temp);

  }

  names(df_read) = make.names(names(df_read))

  return(df_read)
}

Unfortunately, I cannot display the other special characters in a proper way. Is there another encoding style I can use or another way to read in my csv files including all special characters?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>