View source: R/file_utilities.R
| keep_stem_before_txt | R Documentation |
Removes any directory path and optional '.txt' extension from filenames or file paths. This function standardizes text identifiers across Coh-Metrix, GAMET, and other text analysis outputs that may include full paths or extensions in their ID fields.
keep_stem_before_txt(x)
x |
A character vector (or coercible) containing file paths or filenames. Elements may or may not include a '.txt' suffix or any directory path. |
The function handles both forward ('/') and backward ('\') slashes in file paths. If a value has no path and/or no '.txt' suffix, it is returned unchanged (aside from coercion to character).
A character vector where each element is reduced to the final path component, with any trailing '.txt' (case-insensitive) removed. 'NA' values are preserved as 'NA_character_'.
keep_stem_before_txt(c(
"C:/data/3401.txt",
"E:\\\\samples\\\\1002.TXT",
"plain_id",
NA
))
#> [1] "3401" "1002" "plain_id" NA
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.