| file_tree | R Documentation |
Print the directory structure of a given path in a tree-like format using ASCII characters for maximum compatibility across different systems. Optionally, save the result to a log file for record keeping or debugging.
file_tree(
path = ".",
max_depth = 2,
verbose = TRUE,
log = FALSE,
log_path = NULL,
file_name = NULL,
append = FALSE
)
path |
Character. The target root directory path to print. Default is ".". |
max_depth |
Integer. Maximum depth of recursion into subdirectories. Default is 2. |
verbose |
Logical. Whether to print the tree to console. Default is TRUE. |
log |
Logical. Whether to save the tree output as a log file. Default is FALSE. |
log_path |
Character. Directory path to save the log file if log = TRUE. Default is tempdir(). |
file_name |
Character. Custom file name for the log file. If NULL, a name like "file_tree_YYYYMMDD_HHMMSS.log" will be used. |
append |
Logical. If TRUE, appends to an existing file (if present). If FALSE, overwrites the file. Default is FALSE. |
Invisibly returns a character vector containing each line of the file tree.
# Basic usage with current directory:
file_tree()
file_tree(".", max_depth = 3)
# Example with temporary directory and logging:
temp_dir <- tempdir()
file_tree(temp_dir, max_depth = 2, log = TRUE, log_path = tempdir())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.