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

3

6

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
Fellers answered 9/3, 2021 at 9:11 Comment(0)
F
7

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

Fellers answered 9/3, 2021 at 9:11 Comment(0)
S
3

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

Stickinthemud answered 9/4, 2022 at 2:22 Comment(0)
I
0

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 ☺☺☺

Insurable answered 14/2, 2022 at 13:18 Comment(1)
@Jeremy Caney, Hi, Caney, thank you very much for helping edit my reply. Sorry for not being proficient with stackoverflow☺.Insurable

© 2022 - 2024 — McMap. All rights reserved.