0

I did look at the question posted here but I am having separate issues with the fact that I am also trying to unzip the file and after I have downloaded the file from the internet (and saved it locally) R cannot locate my document through the pathway I have provided.

url <- "https://www.eia.gov/electricity/data/eia923/xls/f923_2016.zip"
download.file(url, destfile= "C:\\Users\\reifers\\Google Drive\\CEO Data\\R\\Electricity\\genPortfolioCO\\EIA.GenData.zip")
install.packages("XLConnect")
library(XLConnect)
genData <- readWorksheetFromFile(unzip("C:/Users/reifers/Google Drive/CEO Data/R/Electricity/genPortfolioCO/EIA.GenData", "EIA923_Schedules_2_3_4_5_M_2016.xlsx") 
                                     sheet = 1, startRow = 6, header = TRUE)

This is the error that I currently get

Error: NoSuchMethodException (Java): No constructor matching the given parameters
In addition: Warning message:
In unzip("C:\\Users\\reifers\\Google Drive\\CEO Data\\R\\Electricity\\genPortfolioCO\\EIA.GenData",  :
 error 1 in extracting from zip file
Community
  • 1
  • 1
Sammy
  • 15
  • 5

1 Answers1

2

The warning means that unzip didn't work. That in turn caused an error when reading the worksheet from file. If you work through each step one at a time you'll see what went wrong.

In the call to unzip(), you forgot the file extension. It is EIA.GenData.zip not EIA.GenData. And the file inside it is "EIA923_Schedules_2_3_4_5_M_10_2016.xlsx" not "EIA923_Schedules_2_3_4_5_M_2016.xlsx".

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360