Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R xlsx package error

Tags:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :    java.util.zip.ZipException: invalid code -- missing end-of-block 

Does anyone have this error when you try to use

dat <- read.xlsx("data.xlsx", sheetIndex=1, colIndex=colIndex, rowIndex=rowIndex)? 
like image 716
user3758532 Avatar asked Feb 04 '15 15:02

user3758532


People also ask

What is the package for Xlsx in R?

xlsx package is one of the powerful R packages to read, write and format Excel files. It is a java-based solution and it is available for Windows, Mac and Linux. It works for both Excel 2007 and Excel 97/2000/XP/2003 file formats (xls and xlsx file formats).


1 Answers

I had this problem with a file downloaded from the internet using R command line, for an online course. Found that apparently the download mode needs to be set properly as write-binary (wb) since xlsx is basically a binary file (zip). Who knew?

If that's what you did too, re-download the file with the mode set properly; like:

download.file(fileUrl, destfile='./data/sample.xlsx', mode='wb') 
like image 135
Deep-B Avatar answered Sep 22 '22 20:09

Deep-B