Kaja
Kaja

Reputation: 3057

Reading data from Excel file in r

I want to read data from a big excel file like this:

From the fifth column, from first row until 140, but only 1,3,5,7,.....139 (only 70 values):

wb <- loadWorkbook("D:\\MA\\excel_mix_meiningen.xlsx")
dat <-readWorksheet(wb, sheet=getSheets(wb)[1], startRow=1, endRow=139, startCol=5, endCol=5)
odds <- function(x) {seq(1, length(x), 2)}
odds(unlist(dat))

but I get this error:

Error: OutOfMemoryError (Java): Java heap space

Is there another way to do this job?

Upvotes: 1

Views: 363

Answers (1)

Karsten W.
Karsten W.

Reputation: 18500

The vignette on XlConnect suggests

options(java.parameters = "-Xmx2048m")

before loading the XlConnect package.

EDIT: You could try to reduce the size of the xlsx, maybe delete unneeded columns. You could save the sheet as CSV. You could use RODBC, as @Ananta suggested.

Upvotes: 1

Related Questions