If your problem is specifying the path, try bringing it with the following function:
file.choose()
It will open the folder menu of your operating system. Take two clicks on the filing cabinet you want to import. The path of this file will be sent to the R Console. Something like this:
"/home/user/importR/my1/MeusDados.xlsx"
Copy this path ("/home/user/importR/my1/MeusDados.xlsx"
) without the file name. This way:
"/home/user/importR/my1"
Use it in the function below. So:
setwd("/home/user/importR/my1")
Try to import with the name complete of the archive ("/home/user/importR/my1/MeusDados.xlsx"
):
library(readxl)
meus_dados <- read_excel("/home/user/importR/my1/MeusDados.xlsx")
changed the command, but the error remains > read_excel("MUNICIPALITIES.xlxs") Error:
path
does not exist: ː MUNICÍPIOS.xlxs'– Ingled M Cardoso
@Ingledseiévini, try to declare the whole directory. Example: df <- read_excel("c:/your/folder/your.xlsx file")
– Lucca Ramalho
another thing, you wrote in the read_excel comment("MUNICIPALITIES.xlxs"). the correct is xlsx and not xlxs
– Lucca Ramalho
I had not attempted the error, but corrected and the error persists > read_excel("C:/R cidra/MUNICIPIOS.xlsx") Error:
path
does not exist: pra C:/R cider/MUNICIPIOS.xlsx'– Ingled M Cardoso
Ok. The error message says that the path does not exist. Is the directory really correct? Copy and paste the file, for example, into the "c:/file.xlsx" folder and try read_excel again ("c:/file.xlsx")
– Lucca Ramalho
another thing: the R sometimes does not recognize this bar... try read_excel("c//file.xlsx") or read_excel("c file.xlsx"). Also check that the file format you are wanting to import is the same. (check by right clicking on the file and then on properties)
– Lucca Ramalho
The file is saved in xls, I made a test as you told me read_excel("C: MUNICIPIOS.xlsx"), the result > read_excel("C: MUNICIPIOS.xlsx") Error: ' M' is an unrecognized escape in Character string Starting ""C: M"
– Ingled M Cardoso
Let’s go continue this discussion in chat.
– Lucca Ramalho
If the file is saved in XLS then you should use: df <- read_excel("c:/file.xls"), otherwise it will not be found.
– Lucca Ramalho