Skip to content

Instantly share code, notes, and snippets.

@MonteShaffer
Created October 22, 2020 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MonteShaffer/8555de33cec2b6ffff81c268bcccc041 to your computer and use it in GitHub Desktop.
Save MonteShaffer/8555de33cec2b6ffff81c268bcccc041 to your computer and use it in GitHub Desktop.
R path to Windows
# https://stackoverflow.com/questions/64476043/
# https://stackoverflow.com/questions/1189759/
convertDirectoryR.toWin = function(myDir = getwd()) # "R:/data/state-capitals/final/"
{
cat( normalizePath(myDir) );
writeClipboard( normalizePath(myDir) ); # R:\data\state-capitals\final\
}
openDirectoryR.inWin = function(myDir = getwd()) # "R:/data/state-capitals/final/"
{
cmd = paste("explorer", gsub('/', '\\\\', myDir, fixed=TRUE ) );
suppressWarnings( shell( cmd ) ); # R:\data\state-capitals\final\
}
convertDirectoryWin.toR = function(myDir = readClipboard()) # # R:\data\state-capitals\final\
{
gsub('\\', '/', myDir, fixed=TRUE ); # "R:/data/state-capitals/final/"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment