Skip to contents

Sanitizes file name (without the extension part). Ported and modified from fs::path_sanitize().

Usage

sanitize_filename(filename, replacement = "-")

Arguments

filename

Input file name.

replacement

Replacement for illegal characters.

Value

Sanitized file name.

Examples

x <- " znul/zzz.z>z/\\z "
paste0(sanitize_filename(x), ".rds")
#> [1] "znul-zzz.z-z--z.rds"