High-Performance Open-Source Archive
This article walks through the output features added in
printtree 0.2.1.
demo <- file.path(tempdir(), "printtree-feature-tour")
if (dir.exists(demo)) unlink(demo, recursive = TRUE, force = TRUE)
dir.create(file.path(demo, "R"), recursive = TRUE)
dir.create(file.path(demo, "data", "raw"), recursive = TRUE)
dir.create(file.path(demo, "logs"), recursive = TRUE)
dir.create(file.path(demo, "empty"), recursive = TRUE)
file.create(file.path(demo, "R", "helpers.R"))
#> [1] TRUE
file.create(file.path(demo, "README.md"))
#> [1] TRUE
file.create(file.path(demo, "data", "raw", "sales.csv"))
#> [1] TRUE
file.create(file.path(demo, "logs", "debug.log"))
#> [1] TRUE
file.create(file.path(demo, "test_cache"))
#> [1] TRUEBy default, print_rtree() ends with a displayed
directory/file count.
print_rtree(demo, max_depth = 2)
#> printtree-feature-tour/
#> |-- data/
#> | `-- raw/
#> |-- empty/
#> |-- logs/
#> | `-- debug.log
#> |-- R/
#> | `-- helpers.R
#> |-- README.md
#> `-- test_cache
#>
#> 5 directories, 4 filesSet count_footer = FALSE for compact output.
The ignore argument still supports exact basenames, but
with ignore_type = "auto" it also treats wildcard entries
as glob patterns.
print_rtree(demo, ignore = c("*.log", "test_*"), max_depth = 2)
#> printtree-feature-tour/
#> |-- data/
#> | `-- raw/
#> |-- empty/
#> |-- logs/
#> |-- R/
#> | `-- helpers.R
#> `-- README.md
#>
#> 5 directories, 2 filesYou can opt into regular expression matching for more control.
Use prune = TRUE to hide directories with no displayable
children after ignores and depth limits are applied.
Use quiet = TRUE with return_lines = TRUE
when you want to work with the tree programmatically.
write_tree() writes the same tree output to a text or
Markdown file. Parent directories are created automatically by
default.
tree_md <- file.path(tempdir(), "printtree-feature-tour-output", "tree.md")
write_tree(demo, tree_md, format = "md", title = "Feature Tour Tree")
readLines(tree_md, n = 8)#> [1] "# Feature Tour Tree" ""
#> [3] "```" "printtree-feature-tour/"
#> [5] "|-- data/" "| `-- raw/"
#> [7] "| `-- sales.csv" "|-- empty/"
When the target folder is inside a Git work tree,
git = TRUE annotates changed paths with simple status
markers and includes a legend.
The example is not evaluated when building the vignette so automated checks do not depend on an external Git executable or repository configuration.
Need mirroring services?
Contact our team at info@vpspulse.com.
Mirror powered by VPSpulse
Infrastructure sponsored by VPSPulse & Secure Payments by ArionPay.