Dear R developers, as far as I understand the manual of list.files(), there is only a way to exclude directories from the returned vector if you use list.files recursively. In non recursive mode, there seems to be no way of excluding directories (the include dirs argument does not seem to have any effect). Would it not be more intuitive and practical to allow the switching off of directory names in both cases? Thanks a lot Jannis
Hello, I believe that's a question for r-devel, but good point. It's docummented that in non-recursive calls to list.files subdirectory names are always included. (With a typo, "There always are" instead of "They always are".) Rui Barradas Em 18-11-2012 17:20, Jannis escreveu:> Dear R developers, > > > as far as I understand the manual of list.files(), there is only a way > to exclude directories from the returned vector if you use list.files > recursively. In non recursive mode, there seems to be no way of > excluding directories (the include dirs argument does not seem to have > any effect). Would it not be more intuitive and practical to allow the > switching off of directory names in both cases? > > > Thanks a lot > Jannis > > ______________________________________________ > 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.
You can do the following to remove the directory names from the list: setdiff(list.files(full.names = TRUE), list.dirs(recursive = FALSE)) On Sun, Nov 18, 2012 at 12:20 PM, Jannis <bt_jannis at yahoo.de> wrote:> Dear R developers, > > > as far as I understand the manual of list.files(), there is only a way to > exclude directories from the returned vector if you use list.files > recursively. In non recursive mode, there seems to be no way of excluding > directories (the include dirs argument does not seem to have any effect). > Would it not be more intuitive and practical to allow the switching off of > directory names in both cases? > > > Thanks a lot > Jannis > > ______________________________________________ > 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.-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.