问题
I have Trouble reading in this xlsx file and working with sheet=2 ( "Data") "http://www3.weforum.org/docs/gcr/2015-2016/GCI_Dataset_2006-2015.xlsx"
what i did:
library(readxl)
library(XLConnect)
library("openxlsx")
temp = tempfile(fileext = ".xlsx")
dataURL <- "http://www3.weforum.org/docs/gcr/2015-2016/GCI_Dataset_2006-2015.xlsx"
download.file(dataURL, destfile=temp, mode='wb')
file<- read.xlsx(temp, sheet= 2)
I get the following:
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.OutOfMemoryError: GC overhead limit exceeded
Could someone help? Thnx :)
回答1:
I don't seem to have issues using readxl for this specific file. With the same package I do have issues with specific spreadsheets created by other systems I can't control (the dev is aware of that).
If I run this:
temp = tempfile(fileext = ".xlsx")
dataURL <- "http://www3.weforum.org/docs/gcr/2015-2016/GCI_Dataset_2006-2015.xlsx"
download.file(dataURL, destfile=temp, mode='wb')
test <- readxl::read_excel(temp, sheet =2)
head(test)
I get the following output:
# A tibble: 6 × 159
`The Global Competitiveness Index Historical Dataset © 2005-2015 World Economic Forum `
<chr>
1 IMPORTANT The storage on any data retrieval system and the commercial use of the present data set, or portions of it, is st
2 Placement
3 Placement
4 1
5 1
6 1
# ... with 158 more variables: X__1 <chr>, X__2 <chr>, X__3 <chr>, X__4 <chr>, X__5 <chr>, X__6 <chr>, X__7 <chr>,
# X__8 <chr>, X__9 <chr>, X__10 <chr>, X__11 <chr>, X__12 <chr>, X__13 <chr>, X__14 <chr>, X__15 <chr>, X__16 <chr>,
# X__17 <chr>, X__18 <chr>, X__19 <chr>, X__20 <chr>, X__21 <chr>, X__22 <chr>, X__23 <chr>, X__24 <chr>, X__25 <chr>,
# X__26 <chr>, X__27 <chr>, X__28 <chr>, X__29 <chr>, X__30 <chr>, X__31 <chr>, X__32 <chr>, X__33 <chr>, X__34 <chr>,
# X__35 <chr>, X__36 <chr>, X__37 <chr>, X__38 <chr>, X__39 <chr>, X__40 <chr>, X__41 <chr>, X__42 <chr>, X__43 <chr>,
# X__44 <chr>, X__45 <chr>, X__46 <chr>, X__47 <chr>, X__48 <chr>, X__49 <chr>, X__50 <chr>, X__51 <chr>, X__52 <chr>,
# X__53 <chr>, X__54 <chr>, X__55 <chr>, X__56 <chr>, X__57 <chr>, X__58 <chr>, X__59 <chr>, X__60 <chr>, X__61 <chr>,
# X__62 <chr>, X__63 <chr>, X__64 <chr>, X__65 <chr>, X__66 <chr>, X__67 <chr>, X__68 <chr>, X__69 <chr>, X__70 <chr>,
# X__71 <chr>, X__72 <chr>, X__73 <chr>, X__74 <chr>, X__75 <chr>, X__76 <chr>, X__77 <chr>, X__78 <chr>, X__79 <chr>,
# X__80 <chr>, X__81 <chr>, X__82 <chr>, X__83 <chr>, X__84 <chr>, X__85 <chr>, X__86 <chr>, X__87 <chr>, X__88 <chr>,
# X__89 <chr>, X__90 <chr>, X__91 <chr>, X__92 <chr>, X__93 <chr>, X__94 <chr>, X__95 <chr>, X__96 <chr>, X__97 <chr>,
# X__98 <chr>, X__99 <chr>, X__100 <chr>, ...
NOTE: I am using the current version from github 0.1.1.9000 and not the CRAN 0.1.1.
来源:https://stackoverflow.com/questions/42028408/read-in-online-xlsx-sheet-in-r