Read Excel file into R with XLConnect package from URL

前端 未结 4 1653
轮回少年
轮回少年 2020-12-19 21:32

There are lots of good examples out there on how to read Microsoft Excel files into R with the XLConnect package, but I can\'t find any examples of how to read in an Excel f

4条回答
  •  Happy的楠姐
    2020-12-19 22:20

    You can use RCurl to download the file:

    library(RCurl)
    library(XLConnect)
    appURL <- "https://www.misoenergy.org/Library/Repository/Market%20Reports/20140610_sr_nd_is.xls"
    f = CFILE("exfile.xls", mode="wb")
    curlPerform(url = appURL, writedata = f@ref, ssl.verifypeer = FALSE)
    close(f)
    out <- readWorksheetFromFile(file = "exfile.xls", sheet = "Sheet1", header = TRUE
                          , startRow = 11, startCol = 2, endCol = 15, endRow = 35)
    > head(out)
    Col1 EEI Col3 IESO MHEB Col6 PJM SOCO SWPP TVA WAUE Col12 Other Total
    1 Hour  1 272   NA  768 1671   NA 148  200  -52 198  280    NA   700  4185
    2 Hour  2 272   NA  769 1743   NA 598  200  -29 190  267    NA   706  4716
    3 Hour  3 272   NA  769 1752   NA 598  200  -28 194  267    NA   710  4734
    4 Hour  4 272   NA  769 1740   NA 598  200  -26 189  266    NA   714  4722
    5 Hour  5 272   NA  769 1753   NA 554  200  -27 189  270    NA   713  4693
    6 Hour  6 602   NA  769 1682   NA 218  200  -32 223  286    NA   714  4662
    

提交回复
热议问题