Dear list members, I would like to access a subdirectory given where the work directory has been set. So I have:> getwd()[1] "C:/Users/Lord Adellus/Dropbox/I8child1/Data"> list.files() # give three folders[1] "Least Developed Countries" [4] "Low middle income grouping" "More advanced developing countries and territories"> list.files(path = "../Least Developed Countries") # I want to access now > one of the subdirectoriescharacter(0) But as you can see R does not want to look into the specified subdirectory. I have tried several combination and searched the list but without any great success. Actually: list.files(path = "../...") #goes up one level in the folder structure so I cannot see what the problem is. Thanks in advance. Adel -- View this message in context: http://r.789695.n4.nabble.com/list-files-accessing-subdirectory-as-relative-path-tp4689997.html Sent from the R help mailing list archive at Nabble.com.
MacQueen, Don
2014-May-05 20:46 UTC
[R] list.files accessing subdirectory as relative path?
If 'foo' is a subdirectory of the current working directory, then list.files('foo') lists the files in foo. ".." goes up one level But you did not want to go up one level. You wanted to stay at the same level. (also, '...' has no meaning in pathnames) Try either of list.files(path = "./Least Developed Countries") list.files(path = "Least Developed Countries") -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 5/5/14 12:29 PM, "Adel" <adel.daoud at sociology.gu.se> wrote:>Dear list members, > >I would like to access a subdirectory given where the work directory has >been set. So I have: > >> getwd() >[1] "C:/Users/Lord Adellus/Dropbox/I8child1/Data" > >> list.files() # give three folders > [1] "Least Developed Countries" > [4] "Low middle income grouping" "More advanced >developing countries and territories" > >> list.files(path = "../Least Developed Countries") # I want to access now >> one of the subdirectories >character(0) > >But as you can see R does not want to look into the specified >subdirectory. >I have tried several combination and searched the list but without any >great >success. > >Actually: > >list.files(path = "../...") #goes up one level in the folder structure so >I >cannot see what the problem is. > > >Thanks in advance. >Adel > > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/list-files-accessing-subdirectory-as-relativ >e-path-tp4689997.html >Sent from the R help mailing list archive at Nabble.com. > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
Frede Aakmann Tøgersen
2014-May-06 05:07 UTC
[R] list.files accessing subdirectory as relative path?
Hi ".." is the parent directory whereas "." is the current directory, so you probably want list.files(path = "./Least Developed Countries") instead of list.files(path = "../Least Developed Countries") Yours sincerely / Med venlig hilsen Frede Aakmann T?gersen Specialist, M.Sc., Ph.D. Plant Performance & Modeling Technology & Service Solutions T +45 9730 5135 M +45 2547 6050 frtog at vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender.> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of Adel > Sent: 5. maj 2014 21:30 > To: r-help at r-project.org > Subject: [R] list.files accessing subdirectory as relative path? > > Dear list members, > > I would like to access a subdirectory given where the work directory has > been set. So I have: > > > getwd() > [1] "C:/Users/Lord Adellus/Dropbox/I8child1/Data" > > > list.files() # give three folders > [1] "Least Developed Countries" > [4] "Low middle income grouping" "More advanced > developing countries and territories" > > > list.files(path = "../Least Developed Countries") # I want to access now > > one of the subdirectories > character(0) > > But as you can see R does not want to look into the specified subdirectory. > I have tried several combination and searched the list but without any great > success. > > Actually: > > list.files(path = "../...") #goes up one level in the folder structure so I > cannot see what the problem is. > > > Thanks in advance. > Adel > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/list-files- > accessing-subdirectory-as-relative-path-tp4689997.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.