I am trying to set the working directory to a different subfolder in a function. I expected the print command to print
C:/Users/Blah/Desktop/dir2/SUBFOLDER
instead it prints
C:/Users/Blah/Desktop/dir2
Yet when I run dirs in console I get:
C:/Users/Blah/Desktop/dir2/SUBFOLDER
...(Much longer list)
like I expected. Here is my code:
temp<-function(path)
{
print(path) #output is C:/Users/Blah/Desktop/dir2
setwd(path)
print(getwd())
xml=xmlParse("filename.xml")
...
}
dirs<-list.dirs("C:/Users/Blah/Desktop/dir2")
lapply(dirs,temp)#apply function tempt to every item in dirs
lapply(dirs[-1],temp)
? – lukeAdirs<-list.dirs("C:/Users/Blah/Desktop/dir2"
) is the current directory i.e. in your case"C:/Users/Blah/Desktop/dir2"
. So, this is the one that would be printed first by your function (and then all the subfolders). At least this is the normal behaviour. – LyzandeR