Error reading file . xlsx in R

Asked

Viewed 448 times

1

I have a file .xlsx which I need to read in R. The tab is variable, so I use a code first to check which tab is the most recent, but when using the function read_excel package readxl, returns the following error:

Erro: `path` does not exist: ‘Dados/Previso~es Imperial College.xlsx’

Before, I’m using a setwd to set the folder where all the files are. Inside the folder COVID-19 there is a folder Dados. What I don’t understand is that function excel_sheets, which is from the same package, can read the file normally.

Code I am using:

library(readxl)

setwd("~/GitHub/COVID-19") #Exemplo

abas <- length(excel_sheets("Dados/Previsões Imperial College.xlsx"))

aba <- excel_sheets("Dados/Previsões Imperial College.xlsx")[abas]

dia <- read_excel("Dados/Previsões Imperial College.xlsx", 
                  sheet = aba, range = "B1:B1", col_names = FALSE)

Link to the spreadsheet: https://drive.google.com/file/d/1EB23dikhYUMnaSdQLTA8Bb00FhrdVyJ-/view?usp=sharing

  • 3

    Try renaming the file by removing spaces and accented letters from its name.

  • 1

    I was looking for an explanation for one function of the package to read the file and the other not. But thanks for the tip.

1 answer

2


the last writing of the worksheet name has some hidden character, which causes the path error. Note that when I select the second name, the first name appears selected, and the third not:

inserir a descrição da imagem aqui

Then just delete and rewrite the sheet name (or copy from the previous ones).

  • Thank you! I hadn’t noticed that detail.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.