Braamstruik
Braamstruik

Reputation: 273

Import Excel data into R using openxlsx: Error in file(con, "r") : invalid 'description' argument

I am trying to import the data in my Excel file into R using Openxlsx library:

library(openxlsx)
data <- read.xlsx("datafile.xlsx", sheet = "Sheet1")

However, I get the following error:

Error in file(con, "r") : invalid 'description' argument
In addition: Warning message:
In unzip(xlsxFile, exdir = xmlDir) : error 1 in extracting from zip file

Upvotes: 6

Views: 8598

Answers (3)

Tim Bednall
Tim Bednall

Reputation: 81

There's also another possibility: the XLSX file could be password protected. If you delete the password, then this can fix the error.

Upvotes: 3

Wang Dali
Wang Dali

Reputation: 1

I think the best way to solve this problem is to reset the pathway of your data source. Please do not include any characters without English in your pathway.

setwd("C:\\Users\\your path way (where you store datafile.xlsx)")

P.S. Rstudio2021 seem not friendly to non-English user ☺☺☺

Upvotes: 0

Braamstruik
Braamstruik

Reputation: 273

This error is thrown because your Excel file is open. Save and close the Excel file and try again, it will work.

Upvotes: 7

Related Questions