dirs: Get subdirectories

View source: R/dirs.R

dirsR Documentation

Get subdirectories


If you want only subfolders and no files, use dirs. With recursive = FALSE, dir returns both folders and files. With recursive = TRUE, it returns only files.


dirs(path='.', pattern=NULL, exclude=NULL, all.files=FALSE,
     full.names=FALSE, recursive=FALSE, ignore.case=FALSE) 


path, all.files, full.names, recursive, ignore.case

as for dir

pattern, exclude

optional regular expressions of filenames to include or exclude, respectively.


1. mainDir <- dir(...) without recurse

2. Use file.info to restrict mainDir to only directories.

3. If !recursive, return the restricted mainDir. Else, if length(mainDir) > 0, create dirList to hold the results of the recursion and call dirs for each component of mainDir. Then unlist and return the result.


A character vector of the desired subdirectories.


Spencer Graves


Ramsay, James O., Hooker, Giles, and Graves, Spencer (2009), Functional data analysis with R and Matlab, Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2005), Functional Data Analysis, 2nd ed., Springer, New York.

Ramsay, James O., and Silverman, Bernard W. (2002), Applied Functional Data Analysis, Springer, New York.

See Also

dir, file.info

fda documentation built on May 29, 2024, 11:26 a.m.