1

I am trying to import a txt file with either read.delim or read.csv:

read.delim("DATASET ANALISIS ACV COMPLETO.txt", sep = "\t")

And it returns the following error:

Error in type.convert.default(data[[i]], as.is = as.is[i], dec = dec,  : 
  invalid multibyte string at '<a8>?.0'

I have seen a similar question (Invalid multibyte string in read.csv) but it is a little bit old and I only found answers regarding the specific file he wants to import, but I found the problem affects also the script and it won't read special characters (spanish language): "interacci?n" instead of "interacción"

I have found that the only solution is to downgrade the R version to 4.1.3 from 4.3.0. I have tried every solution from the previous question I mentioned, but I just want to solve this in general, not every time that I want to import a file or write an script.

Marc Le Bihan
  • 2,308
  • 2
  • 23
  • 41
Airam
  • 11
  • 2
  • Don't you have a way through these functions, to add a charset parameter? – Marc Le Bihan Jun 14 '23 at 10:24
  • I may have, but as I say I don't want to be adding parameters every time I want to import a file that never gave me any problem until I updated R version to 4.3.0 – Airam Jun 14 '23 at 10:28
  • I guess your file's encoding is not UTF-8 but that's what R expects. So either change your file's encoding or tell R which encoding you are using with the `fileEncoding` argument to `read.csv`. – Robert Hacken Jun 14 '23 at 11:48
  • I made sure my file's encoding is UTF-8 and it returned the same error. Also, why would the encoding matter in version 4.3.0 and not in 4.1.3? – Airam Jun 14 '23 at 13:19
  • I thought there might have been some changes in encoding defaults between the versions but maybe that's not the case. Can you share your input file (or a part of it with these problematic characters)? – Robert Hacken Jun 14 '23 at 15:06

0 Answers0