1

After setting locale and main path with code below:

Sys.setlocale(category = "LC_CTYPE", locale = "chinese")
setwd('D:/lyz用户名/R可视化/')

I used readxl::read_excel() and xlsx::read.xlsx() to read the path of excel file containing Chinese characters respectively, the former returned the error of Error in utils::unzip(zip_path, list = TRUE), while the latter can be parsed correctly.

readxl::read_excel("./data/制造业PMI.xlsx", sheet = 'Sheet1')

Out:

Error in utils::unzip(zip_path, list = TRUE) : 
  zip file 'D:\lyz鏂囦欢\R缁樺浘绀轰緥\data\锟斤拷锟斤拷业锟斤拷锟斤拷锟斤拷业PMI.xlsx' cannot be opened
In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) : path[1]="./data/制造业PMI.xlsx": 绯荤粺鎵句笉鍒版寚瀹氱殑鏂囦欢銆?

Meanwhile, xlsx::read.xlsx could read file correctly.

xlsx::read.xlsx("./data/制造业PMI.xlsx", sheetName="Sheet1")

How can I read and parse paths containing Chinese characters normally by readxl::read_excel()? Thanks.

ah bon
  • 9,293
  • 12
  • 65
  • 148

0 Answers0