Created
September 4, 2017 12:42
-
-
Save willgdjones/cc414cad004bf1c875fc7c25c9d73cf9 to your computer and use it in GitHub Desktop.
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
function (package = NULL) | |
{ | |
z <- list() | |
z$R.version <- R.Version() | |
z$platform <- z$R.version$platform | |
if (nzchar(.Platform$r_arch)) | |
z$platform <- paste(z$platform, .Platform$r_arch, sep = "/") | |
z$platform <- paste0(z$platform, " (", 8 * .Machine$sizeof.pointer, | |
"-bit)") | |
z$locale <- Sys.getlocale() | |
if (.Platform$OS.type == "windows") { | |
z$running <- win.version() | |
} | |
else if (nzchar(Sys.which("uname"))) { | |
uname <- system("uname -a", intern = TRUE) | |
os <- sub(" .*", "", uname) | |
z$running <- switch(os, Linux = if (file.exists("/etc/os-release")) { | |
tmp <- readLines("/etc/os-release") | |
t2 <- if (any(startsWith(tmp, "PRETTY_NAME="))) sub("^PRETTY_NAME=", | |
"", grep("^PRETTY_NAME=", tmp, value = TRUE)[1L]) else if (any(startsWith(tmp, | |
"NAME"))) sub("^NAME=", "", grep("^NAME=", tmp, | |
value = TRUE)[1L]) else "Linux (unknown distro)" | |
sub("\"(.*)\"", "\\1", t2) | |
} else if (file.exists("/etc/system-release")) { | |
readLines("/etc/system-release") | |
}, Darwin = { | |
ver <- readLines("/System/Library/CoreServices/SystemVersion.plist") | |
ind <- grep("ProductUserVisibleVersion", ver) | |
ver <- ver[ind + 1L] | |
ver <- sub(".*<string>", "", ver) | |
ver <- sub("</string>$", "", ver) | |
ver1 <- strsplit(ver, ".", fixed = TRUE)[[1L]][2L] | |
sprintf("%s %s %s", ifelse(as.numeric(ver1) < 12, | |
"OS X", "macOS"), switch(ver1, 6 = "Snow Leopard", | |
7 = "Lion", 8 = "Mountain Lion", 9 = "Mavericks", | |
10 = "Yosemite", 11 = "El Capitan", 12 = "Sierra", | |
13 = "High Sierra", ""), ver) | |
}, SunOS = { | |
ver <- system("uname -r", intern = TRUE) | |
paste("Solaris", strsplit(ver, ".", fixed = TRUE)[[1L]][2L]) | |
}, uname) | |
} | |
if (is.null(package)) { | |
package <- grep("^package:", search(), value = TRUE) | |
keep <- vapply(package, function(x) x == "package:base" || | |
!is.null(attr(as.environment(x), "path")), NA) | |
package <- .rmpkg(package[keep]) | |
} | |
pkgDesc <- lapply(package, packageDescription, encoding = NA) | |
if (length(package) == 0) | |
stop("no valid packages were specified") | |
basePkgs <- sapply(pkgDesc, function(x) !is.null(x$Priority) && | |
x$Priority == "base") | |
z$basePkgs <- package[basePkgs] | |
if (any(!basePkgs)) { | |
z$otherPkgs <- pkgDesc[!basePkgs] | |
names(z$otherPkgs) <- package[!basePkgs] | |
} | |
loadedOnly <- loadedNamespaces() | |
loadedOnly <- loadedOnly[!(loadedOnly %in% package)] | |
if (length(loadedOnly)) { | |
names(loadedOnly) <- loadedOnly | |
pkgDesc <- c(pkgDesc, lapply(loadedOnly, packageDescription)) | |
z$loadedOnly <- pkgDesc[loadedOnly] | |
} | |
z$matprod <- as.character(options("matprod")) | |
es <- extSoftVersion() | |
z$BLAS <- as.character(es["BLAS"]) | |
z$LAPACK <- La_library() | |
class(z) <- "sessionInfo" | |
z | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment