Cross-platform path building, encoding detection, temporary file management, and miscellaneous helpers.
This module contains the following functions:
build_path — Build file path safely (cross-platform)detect_encoding — Detect file encodingnormalize_file_newlines — Normalize line endings in a filemanaged_tempdir — Create and manage temporary directory with automatic cleanupmanaged_tempfile — Create and manage temporary file with automatic cleanupget_supported_extensions — Get supported file extensionssave_session_info — Save sessionInfo() for reproducibilityrclade_logo — Display Rclade ASCII art logobuild_pathWrapper 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_encodingDetect 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_newlinesReads 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_tempdirCreate 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_tempfileCreates 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_extensionsGet supported file extensions
Usage:
get_supported_extensions()
Value:
Named list of supported extensions by category.
Examples:
get_supported_extensions()
save_session_infoSave 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_logoPrints 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()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.