Problem type Std::bad_alloc

Asked

Viewed 592 times

3

I’m trying to read a database that’s in .xlsx. It has about 90,000 rows and 70 columns. I’m using the package openxlsx and I’ve made the mistake:

Error in eval(substitute(expr), envir, enclos) : std::bad_alloc

The desktop I’m using is an Intel Core i5-33330, RAM: 8.00 GB and W7-32 bits. What to do?

  • 1

    I’d try the function read_excel package readxl before seeing what could be this mistake...

  • I changed the function, but I kept having the same problem.

  • 1

    Can you open this excel? from outside the R? If yes, save it as csv and read it as csv itself..

  • I had already done this with another database and it worked, but as the problem seemed to be recurrent I would like to know if there is something else to do, because all the bases here of the work are in excel. Thank you very much.

  • 2

    This error has to do with the size of the base itself... Check this topic: https://github.com/tidyverse/readxl/issues/150 Maybe installing the development version of readxl works. Try doing devtools::install_github("tidyverse/readxl")

  • I tried, but it still didn’t work. Error appeared: Error in eval(substitute(expr), envir, enclos) : cannot allocate vector of size 284.0 Mb

  • 4

    This means that the problem is really RAM. What if you read the file in two parts? In this new version, has the argument n_max. You could do something like this: x1 <- read_excel(arq, n_max = 45000), x2 <- read_excel(arq, skip = 45001, header = FALSE)

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.