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()