Reputation: 39
library("readxl")
my_data <- read_excel("GVA.xlsx")
my_data
however the console says the path does not exist. How can I import excel/csv files and know that the file will always be found.
Why does this not work?
p.s. I am new to R
Upvotes: 1
Views: 12129
Reputation: 301
The following article might help: https://forum.posit.co/t/read-excel-file-from-r-project/158530
The easiest way is, of course, to put your Excel file in the same working directory as your R code. Simply put, your "GVA.xlsx" file has to be in the same folder as your "code.r" file
Otherwise, just as the article mentioned, you need to set your working directory by setwd(), hope this helps!
Upvotes: 0
Reputation: 20342
Well, is 'GVA.xlsx' in your working directory? If not, R can't find it because you're not mapping to anything outside of your current directory. You can navigate to the file by clicking on: File > Import Dataset > From Excel. Browse to your file and set any required import options. R will actually create the code to map to the file in question.
Upvotes: 0