Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error message using read_excel "Error: std::bad_alloc"

Tags:

r

readxl

I'm trying to open an Excel file with the read_excel() function from the readxl package. But I don't know how to specify the path to the Excel file.

When I enter the file path by following the steps given in the answer, I receive the error:

"Error: std::bad_alloc".

like image 254
ribery77 Avatar asked Jul 02 '15 12:07

ribery77


3 Answers

First load the package:

library(readxl)

According to the package development page, you just have to specify the file name as a string, for example:

read_excel("my-old-spreadsheet.xls")
read_excel("my-new-spreadsheet.xlsx")

You can also specify the name or number of sheet:

read_excel("my-spreadsheet.xls", sheet = "data")
read_excel("my-spreadsheet.xls", sheet = 2)

Make sure you are in the correct directory using getwd(). If not, change it using setwd()

like image 80
Paulo MiraMor Avatar answered Oct 16 '22 21:10

Paulo MiraMor


As noted in the comments, that error message is caused by an issue with the file size. See the package issue at: https://github.com/hadley/readxl/issues/150.

like image 41
Sam Firke Avatar answered Oct 16 '22 20:10

Sam Firke


Just encountered this problem, when re-reading a file I read successfully!

As vladdsm points out on github, closing and re-opening Rstudio can solve the problem https://github.com/tidyverse/readxl/issues/150#issuecomment-236883769

like image 1
psychonomics Avatar answered Oct 16 '22 20:10

psychonomics