1

When I read a CSV file R adds strange symbols at the very beginning, like this:

п.їCategory

But in the original file it's just

"Category"

Because of that problem I cannot refer to this variable.

I already checked the coding of the file, it's UTF-8. It contains some unusual symbols later (German umlauts), but not as varible names, so I don't understand why this problem appears here. Are there any ideas?..

data_id = read.table("subject-3.csv", stringsAsFactors = F, header = T, fill = T, sep="\t", na.strings=c("","NA"))
Alex M
  • 129
  • 1
  • 7
  • try with encoding = "UTF-8" – Pawel Stradowski Jul 03 '19 at 16:24
  • How did you check the encoding? Does this just affect the first column name? Is there a byte-order-marker (BOM) in the file? (possible duplicate: https://stackoverflow.com/questions/21624796/read-a-utf-8-text-file-with-bom) – MrFlick Jul 03 '19 at 16:35
  • @MrFlick thank you! I found out indeed that the encoding was wrong (because the file was created by using Mac, which I didn't know). I never had this problem before, because all other files were created on Windows. After using R on Mac to read the table, I got rid of this problem. I also tried your suggested method with BOM, but it didn't work (all data are read just as a single string, when there should be a table). – Alex M Jul 04 '19 at 10:24
  • @PawelStradowski I found out indeed that the encoding was wrong (because the file was created by using Mac, which I didn't know). I never had this problem before, because all other files were created on Windows. After using R on Mac to read the table, I got rid of this problem. – Alex M Jul 04 '19 at 10:25
  • @MrFlick I used PSPad to convert the file into UTF-8, but as I understand now it didn't work properly. – Alex M Jul 04 '19 at 10:26

0 Answers0