Skip to content

Instantly share code, notes, and snippets.

@skurscheid
Created July 8, 2016 04:54
Show Gist options
  • Save skurscheid/0fd326d9cb11c77a106b36a82c946d63 to your computer and use it in GitHub Desktop.
Save skurscheid/0fd326d9cb11c77a106b36a82c946d63 to your computer and use it in GitHub Desktop.
amILocal.R
# 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