ID EN
Vector & List

list.files

R Base 3.6.2 🇮🇩 Bahasa Indonesia

Fungsi-fungsi ini menghasilkan vektor karakter dari nama file atau direktori dalam direktori bernama.

Syntax

R
list.files(path = ".", pattern = NULL, all.files = FALSE,
           full.names = FALSE, recursive = FALSE,
           ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)<p></p><p>       dir(path = ".", pattern = NULL, all.files = FALSE,
           full.names = FALSE, recursive = FALSE,
           ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)</p><p>list.dirs(path = ".", full.names = TRUE, recursive = TRUE)</p>

Arguments

Parameter Deskripsi
path a character vector of full path names; the default corresponds to the working directory, getwd(). Tilde expansion (see path.expand) is performed. Missing values will be ignored. Elements with a marked encoding will be converted to the native encoding.
pattern an optional regular expression. Only file names which match the regular expression will be returned.
all.files a logical value. If FALSE, only the names of visible files are returned. If TRUE, all file names will be returned.
full.names a logical value. If 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.
recursive logical. Should the listing recurse into directories?
ignore.case logical. Should pattern-matching be case-insensitive?
include.dirs logical. Should subdirectory names be included in recursive listings? (They always are in non-recursive ones).
no.. logical. Should both "." and ".." be excluded also from non-recursive listings?

Return Value

Vektor karakter berisi nama file di direktori yang ditentukan (kosong jika tidak ada file). Jika suatu jalur tidak ada atau bukan merupakan direktori atau tidak dapat dibaca maka jalur tersebut akan dilewati. File diurutkan berdasarkan abjad, pada path lengkap jika nama lengkap = TRUE. list.dirs secara implisit memiliki all.files = TRUE, dan jika rekursif = TRUE, jawabannya mencakup path itu sendiri (asalkan direktori tersebut dapat dibaca).

Contoh

Example
R
# NOT RUN {
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)
# }

See Also

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.