This function mimics the tree shell command in Linux. It shows directories in a tree structure as an ASCII art. Not all options were enabled.

dir_tree(path = "./", level = 3, type = "dir_last",
  all.files = FALSE)

Arguments

path

character[1] Root path for the construction of the ASCII representation.

level

integer[1] A positive integer that is how many levels to show. Default is 3. Use Inf to not limit.

type

character[1] This is the display mode. Default is "dir_last" that keeps files at the beginning and directories to the end. The value "none" uses alphabetical order..

all.files

logical[1] Using TRUE, hidden files and directories are showed.

Value

Returns the directory list as invisible.

See also

tree() for an implementation that calls tree on Linux. Also, dir(), list.files() and list.dirs() can be useful in many circumstances.

Examples

# NOT RUN { # Tree of your currend directory. getwd() dir_tree() dir_tree(type = "none") dir_tree(all.files = TRUE) # Tree of a installed package. dir_tree(system.file(package = "lattice"), level = 1) dir_tree(system.file(package = "lattice"), level = 2) dir_tree(system.file(package = "lattice"), level = 3) dir_tree(system.file(package = "lattice"), level = 4) m <- dir_tree(system.file(package = "MASS"), level = 2) str(m) # }