Update: A list.dirs function was added to the base package in edition 54353, which was included in the release of R-2.13.0 in April 2011.
list.dirs(path = ".", full.names = TRUE, recursive = TRUE)
So, my function below was only useful for a few months. :)
I could not find the basic R function to do this, but it would be pretty easy to write my own use:
dir()[file.info(dir())$isdir]
Update: here's the function (now fixed for Timothy Jones comment):
list.dirs <- function(path=".", pattern=NULL, all.dirs=FALSE, full.names=FALSE, ignore.case=FALSE) { # use full.names=TRUE to pass to file.info all <- list.files(path, pattern, all.dirs, full.names=TRUE, recursive=FALSE, ignore.case) dirs <- all[file.info(all)$isdir] # determine whether to return full names or just dir names if(isTRUE(full.names)) return(dirs) else return(basename(dirs)) }
Joshua Ulrich Jan 20 '11 at 16:41 2011-01-20 16:41
source share