inst/docs/en/reference/utilities.md

Utilities

Cross-platform path building, encoding detection, temporary file management, and miscellaneous helpers.

This module contains the following functions:

build_path

Wrapper around file.path() to ensure consistent path construction. Never use paste() or sprintf() for path construction.

Usage:

build_path(...)

Arguments:

| Argument | Description | |----------|-------------| | ... | Path components. |

Value:

Character. Constructed path.

Examples:

build_path("data", "output", "tree.pdf")

detect_encoding

Detect file encoding

Usage:

detect_encoding(filepath, n_lines = 10)

Arguments:

| Argument | Description | |----------|-------------| | filepath | Character. Path to file. | | n_lines | Integer. Number of lines to sample. |

Value:

Character. Detected encoding name.

Examples:

detect_encoding("labels.txt")

normalize_file_newlines

Reads a file, normalizes line endings, and writes it back.

Usage:

normalize_file_newlines(filepath)

Arguments:

| Argument | Description | |----------|-------------| | filepath | Character. Path to file. |

Value:

Invisibly returns the filepath.

Examples:

normalize_file_newlines("labels.txt")

managed_tempdir

Create and manage temporary directory with automatic cleanup

Usage:

managed_tempdir(pattern = "rclade_")

Arguments:

| Argument | Description | |----------|-------------| | pattern | Character. Directory name pattern. |

Value:

List with path and cleanup function.

Examples:

d <- managed_tempdir()

managed_tempfile

Creates a temporary file and registers cleanup via on.exit().

Usage:

managed_tempfile(pattern = "rclade_", fileext = ".tmp", tmpdir = tempdir())

Arguments:

| Argument | Description | |----------|-------------| | pattern | Character. File name pattern. | | fileext | Character. File extension. | | tmpdir | Character. Temporary directory. Default: tempdir(). |

Value:

List with path and cleanup function.

Examples:

tmp <- managed_tempfile(pattern = "tree_", fileext = ".nwk")
writeLines("(A:1,B:1);", tmp$path)
# File is automatically cleaned up when function exits

get_supported_extensions

Get supported file extensions

Usage:

get_supported_extensions()

Value:

Named list of supported extensions by category.

Examples:

get_supported_extensions()

save_session_info

Save sessionInfo() for reproducibility

Usage:

save_session_info(file = "session_info.txt")

Arguments:

| Argument | Description | |----------|-------------| | file | Output file path (default "session_info.txt") |

Value:

Invisibly returns sessionInfo

Examples:

save_session_info("session_info.txt")

rclade_logo

Prints a stylized ASCII art logo for Rclade to the console.

Usage:

rclade_logo(show_version = TRUE, show_tagline = TRUE)

Arguments:

| Argument | Description | |----------|-------------| | show_version | Logical. Whether to show version number. Default: TRUE | | show_tagline | Logical. Whether to show tagline. Default: TRUE |

Value:

Invisible NULL

Examples:

rclade_logo()

中文 | 文档首页



Try the Rclade package in your browser

Any scripts or data that you put into this service are public.

Rclade documentation built on Sept. 26, 2026, 5:07 p.m.