I am trying to use readxl::read_excel to import tabular data from an excel spreadsheet (.xlsx and .xls) into R. I have had success with this function when reading spreadsheets from Desktop, but I am having trouble reading from my Documents folder now.
I tried reading both .xlsx and .xls formats of the same file and got 2 different error messages.
# Check the working directory
[1] "\\\\isdowfsv04/D100Home/e525902"
# Read .xlsx
specs <- read_excel("Class Specs Sept 2016.xlsx")
Error: 'exdir' does not exist
# Read .xls
specs <- read_excel("Class Specs Sept 2016.xls")
Error: path[1]="\\isdowfsv04/D100Home/e525902/Class Specs Sept 2016.xls": Access is denied
The second message made me think I don't have permission to read/write data here, but I create folders/files here all the time. I have even used another R library, readr package, to import .csv files from this same directory.
# Using readr to import .csv version of the file works fine.
specs <- read_csv("\\\\isdowfsv04/D100Home/e525902/Class Specs Sept 2016.csv")
Based on other posts I've seen, it seems like a permission issue, but it's unclear to me how to fix it.
I tried using Sys.setenv() to change the temporary folders location to somewhere I know I have permission to write (i.e., Desktop) because I thought readxl used these paths when reading the data. But that didn't work because I got the exact same error messages.
Sys.getenv(c("TEMP", "TMP"))
TEMP TMP
"C:\\Users\\e525902\\AppData\\Local\\Temp" "C:\\Users\\e525902\\AppData\\Local\\Temp"
# Change temp file paths to the Desktop
Sys.setenv(TEMP = "C:\\Users\\e525902\\Desktop")
Sys.setenv(TMP = "C:\\Users\\e525902\\Desktop")
I am using a PC at work and the Documents folder is actually a network drive. I have used read_excel to import .xlsx files from other network folders, but this one is giving me trouble. Below is more information on the system I'm using.
Sys.info()
sysname release version
"Windows" "7 x64" "build 7601, Service Pack 1"
nodename machine login
"10004053WDT" "x86-64" "e525902"
user effective_user
"e525902" "e525902"
search()
[1] ".GlobalEnv" "package:readr" "package:readxl" "tools:rstudio" "package:stats"
[6] "package:graphics" "package:grDevices" "package:utils" "package:datasets" "package:methods"
[11] "Autoloads" "package:base"
# R version
version$version.string
version.string R version 3.2.5 (2016-04-14)