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?
I’d try the function
read_excelpackagereadxlbefore seeing what could be this mistake...– Daniel Falbel
I changed the function, but I kept having the same problem.
– Flavio Silva
Can you open this excel? from outside the R? If yes, save it as csv and read it as csv itself..
– Daniel Falbel
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.
– Flavio Silva
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")– Daniel Falbel
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– Flavio Silva
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)– Daniel Falbel