Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mjsteinbaugh/0837fb32bf5c14488ce92065cc065767 to your computer and use it in GitHub Desktop.
Save mjsteinbaugh/0837fb32bf5c14488ce92065cc065767 to your computer and use it in GitHub Desktop.
# Normalize a Windows file path from the clipboard.
#
# Single backslash is an escape character in R.
# Sanitize `\` to either `\\` or `/` (preferred).
#
# Otherwise, you'll hit this error:
# Error: '\p' is an unrecognized escape in character
#
# Note that this only works in R running on Windows.
# Linux/macOS R doesn't have the `readClipboard()` function.
normalizePath(
path = readClipboard(),
winslash = "/",
mustWork = TRUE
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment