本次修改加 fileEncoding = "GBK"读取成功!修改过程如下:
原代码:
> saledata <- read.csv(file = "./data/catering_sale_all.csv", header = TRUE)
Error in make.names(col.names, unique = TRUE) :
'<c8><d5><c6><da>'多字节字符串有错
方法1:加上encoding = "UTF-8",报错原因,运行系统为Windows,加UIF-8没用
> saledata <- read.csv(file = "./data/catering_sale.csv", header = TRUE,encoding = "UTF-8")
Error in make.names(col.names, unique = TRUE) :
'<c8><d5><c6><da>'多字节字符串有错
方法2:将UIF-8改为GBK还是没用
> saledata <- read.csv(file = "./data/catering_sale.csv", header = TRUE,as.is = TRUE,encoding = "GBK")
Error in make.names(col.names, unique = TRUE) :
'<c8><d5><c6><da>'多字节字符串有错
方法3:加 fileEncoding = "GBK"读取成功!
> saledata <- read.csv(file = "./data/catering_sale.csv", header = TRUE, fileEncoding = "GBK")
>
参考:R语言报错:Error in make.names(col.names, unique = TRUE) : invalid multibyte string 1_mangoJohn的博客-CSDN博客