I'm trying to work with R using a directory in my external hard drive as working directory. I can set the working directory to where I want, but when I use list.files
R can't see anything. I also can't use read.delim
to load a file.
For example:
> rm(list = ls())
> WD<-"../../../Volumes/My_HD/my_working_directory"
> setwd(WD)
> getwd()
[1] "/Volumes/My_HD/my_working_directory"
So far so good, but then:
> list.files(WD)
character(0)
Whilst I would expect a list of the files that I know are there and that I can see and open with Finder and with the Terminal. Actually the R script itself is inside that directory.
If then I try to open a file I get something like this:
> myfile <- read.delim(paste(WD,"/file_name", sep = ""), header = T)
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file '../../../Volumes/My_HD/my_working_directory/file_name': No such file or directory
I thought I was doing something wrong specifying the path to the directory, but I tried point and click from RStudio (Session>Set Working Directory and either >To Source File Location or >Choose Directory...) and got the same unhappy result.
I'm using R version 2.15.1 on a MacBookPro (OS X 10.7.05). I'm running R from RStudio version 0.97.551, but the problem is not related to RStudio as it happens also when I try directly on R.
Any help will be very much appreciated. Thanks.