Created
July 8, 2016 04:54
-
-
Save skurscheid/0fd326d9cb11c77a106b36a82c946d63 to your computer and use it in GitHub Desktop.
amILocal.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# checks if script is being run on a machine with given name | |
# useful if code e.g. requires dynamic allocation of host-dependeten | |
# file paths | |
amILocal <- function(machinename = NULL){ | |
if(is.null(machinename)) stop("Machinename is missing") | |
m <- Sys.info()["nodename"] | |
mn <- unlist(lapply(strsplit(m, "\\."), function(x) x[1])) | |
if (mn == machinename) { | |
return(TRUE) | |
} else { | |
return(FALSE) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment