list.files(path = ".", pattern = NULL, all.files = FALSE,
full.names = FALSE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE) dir(path = ".", pattern = NULL, all.files = FALSE,
full.names = FALSE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
list.dirs(path = ".", full.names = TRUE, recursive = TRUE)
getwd()
. Tilde
expansion (see path.expand
) is performed. Missing
values will be ignored.FALSE
, only the
names of visible files are returned. If TRUE
,
all file names will be returned.TRUE
, the directory
path is prepended to the file names to give a relative file path.
If FALSE
, the file names (rather than paths) are returned."."
and ".."
be excluded
also from non-recursive listings?""
if there were no files. If a
path does not exist or is not a directory or is unreadable it
is skipped, with a warning. The files are sorted in alphabetical order, on the full path
if full.names = TRUE
. list.dirs
implicitly has all.files = TRUE
, and if
recursive = TRUE
, the answer includes path
itself
(provided it is a readable directory).file.info
, file.access
and files
for many more file handling functions and
file.choose
and choose.files
for interactive selection. glob2rx
to convert wildcards (as used by system file
commands and shells) to regular expressions. Sys.glob
for wildcard expansion on file paths.list.files(R.home())
## Only files starting with a-l or r
## Note that a-l is locale-dependent, but using case-insensitive
## matching makes it unambiguous in English locales
dir("../..", pattern = "^[a-lr]", full.names = TRUE, ignore.case = TRUE)
list.dirs(R.home("doc"))
list.dirs(R.home("doc"), full.names = FALSE)
Run the code above in your browser using DataLab