Utilities

library(mintyr)

Small helpers: file-path parts with get_path_info(), and the example files shipped with the package.

Parts of file paths: get_path_info()

paths <- c("C:/Users/foo/Documents/report.xlsx",
           "/home/user/.bashrc",
           "relative/path/to/data.csv",
           ".hidden.tar.gz",
           NA_character_)

# Mode B: filename only, extension stripped (default)
get_path_info(paths)
#> [1] "report"      ".bashrc"     "data"        ".hidden.tar" NA

# Mode B: filename only, extension preserved
get_path_info(paths, rm_extension = FALSE)
#> [1] "report.xlsx"    ".bashrc"        "data.csv"       ".hidden.tar.gz"
#> [5] NA

# Mode B: full normalised path, extension stripped
get_path_info(paths, rm_path = FALSE)
#> [1] "C:/Users/foo/Documents/report" "/home/user/.bashrc"           
#> [3] "relative/path/to/data"         ".hidden.tar"                  
#> [5] NA

# Mode A: extract the 2nd path segment
get_path_info(paths, n = 2)
#> [1] "foo"  "user" "path" NA     NA

# Mode A: extract the last segment with extension stripped (n = -1 linkage)
get_path_info(paths, n = -1, rm_extension = TRUE)
#> [1] "report"      ".bashrc"     "data"        ".hidden.tar" NA

# Mode A: range extraction
get_path_info(paths, n = c(2, 3))
#> [1] "foo/Documents" "user/.bashrc"  "path/to"       NA             
#> [5] NA

Example files: mintyr_example()

# Get path to an example file
mintyr_example("csv_test1.csv")
#> [1] "C:/Users/tony2/AppData/Local/Temp/Rtmp6psovW/Rinst8d44679c53fa/mintyr/extdata/csv_test1.csv"

List example files: mintyr_examples()

# List all example files
mintyr_examples()
#> [1] "csv_test1.csv"         "csv_test2.csv"         "multiheader_test.xlsx"
#> [4] "xlsx_test1.xlsx"       "xlsx_test2.xlsx"