File Location Help

Below is the code provided to me by my professor to load an R file. I have copied and pasted the file location from the file manager.

rm(list = ls())

#Import Packages
require(xlsx)

#Import Data
data <- read.xlsx("C:/Homework/Novice Data v2.xls", 1)

#Looking at the data types and overview of the data
str(data)

The return of this is: Error in loadWorkbook(file, password = password) :
Cannot find C:/Homework/Novice Data v2.xls

What am I doing wrong here? I have an assignment due and I cannot move to the next portion without getting over this hurdle.
Thanks in advance.

This means that R can't find that specific file on the given location. Double check the location and the precise name of the file (including the extension), have in mind that R is case sensitive.

I have copied as text from file manager. I have even tried file.exists(C:/Homework) and I get "+" as a return result. I apologize, I have about 5 hours of RStudio experience at this point.

Let's check what is inside that folder, run this command to get a list of the files.

list.files(path="C:\\Homework")

list.files(path="C:\Homework")
[1] "Novice Data v2.xls.R"

In case you haven't noticed, the file has double extension (i.e. .xls.R) this doesn't seem right, you should check on that, if this is an Excel file it should only have a .xls extension.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.