0
votes

I am trying to import a xlsx file into R but I keep getting this error when copying the file path. The file path is "C:\Users\aj\Downloads" so I have been writing:

library(openxlsx)

Data <- read.xlsx(paste0(C:\Users\aj\Downloads, '\Data.xlsx'))

I tried switching to "/" from "" and I got a different error that stated unexpected input. Does anybody know what I am missing or if I am even on the right track?

1
Have you set all the text in the paste0 function in inverted commas? paste0("C:\Users\aj\Downloads", "\Data.xlsx") - Peter
Have you tried double back-slash Data <- read.xlsx('C:\\Users\\aj\\Downloads\\Data.xlsx')? The back-slash often works as an escape-character. - WilliamGram

1 Answers

0
votes

As a work-around: you could use the Import Dataset button in the Environment pane. It will import the dataset for you and also show you the correct command.