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".
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()
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With