0
library(readr)

Disease<-read_csv(file = "C:/Users/bryan/Documents/Data Science 
Project/CT5163_Project_2021_22_Disease_final.csv")

ForestFire<-read_csv(file = "C:/Users/bryan/Documents/Data Science 
Project/CT5163_Project_2021_22_ForestFire_final.csv")

Salary<-read_csv(file = "C:/Users/bryan/Documents/Data Science 
Project/CT5163_Project_2021_22_Salary_final.csv")

The first two files read perfectly with no issues. however with the salary_final.csv, when read , an error comes back with the following "Error in nchar(x, "width") : invalid multibyte string, element 1"

Anyone know why and what i can do to fix this?

mb67
  • 1
  • 3
  • Have you tried with other reading funcs, as in `data.table::fread`, `utils::read.csv`, or `vroom::vroom`? – r2evans Mar 18 '22 at 20:49
  • 2
    Where did the CSV file come from? Do you know what character encoding the file uses? You might want to ask whomever gave you the file to see what encoding you should be using to read in the files. Maybe try `locale=locale(encoding="latin1")` in the call to `read_csv`? It's hard to say for sure without some sort of [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Mar 18 '22 at 20:49
  • You are missing an ending parentheses on the Salary_final.csv – Daniel L Mar 18 '22 at 20:54
  • hey, i tried locale=locale(encoding="latin1") and it worked ! thanks man. – mb67 Mar 18 '22 at 20:56
  • yeah i saw that, still get the same message when i fixed that. not having locale=locale(encoding="latin1") was the problem. – mb67 Mar 18 '22 at 20:58

1 Answers1

0

Try

locale=locale(encoding="latin1")

in the call to read_csv

Wai Ha Lee
  • 8,173
  • 68
  • 59
  • 86
Dubukay
  • 1,251
  • 6
  • 12