-
Notifications
You must be signed in to change notification settings - Fork 6
Add function write_sessioninfo() #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1265ced
3c0f8ed
af85602
eed315d
abfb9be
cb17d0a
0185d1e
7f77bdb
88e234b
2acfebd
a613eed
bd712be
4c0dc7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #' Write essential session info to a file or connection | ||
| #' | ||
| #' Writes essentials of | ||
| #' \code{\link[sessioninfo:session_info]{sessioninfo::session_info()}} | ||
| #' to a file or connection in order to | ||
| #' maintain versionable documentation of a workflow and aid | ||
| #' reproducibility. | ||
| #' | ||
| #' The following information is written: | ||
| #' \itemize{ | ||
| #' \item{essential platform info: version, os, system, ctype} | ||
| #' \item{essential info on loaded packages: package, loadedversion, date, | ||
| #' source if different from CRAN.} | ||
| #' } | ||
| #' | ||
| #' @param file A file path or a \code{\link[base]{connection}}. | ||
| #' | ||
| #' @importFrom sessioninfo | ||
| #' platform_info | ||
| #' package_info | ||
| #' @importFrom stringr | ||
| #' str_detect | ||
| #' @importFrom utils | ||
| #' write.table | ||
| #' capture.output | ||
| #' @importFrom rlang | ||
| #' .data | ||
| #' @importFrom dplyr | ||
| #' mutate | ||
| #' select | ||
| #' | ||
| #' @export | ||
| #' | ||
| #' @examples | ||
| #' \dontrun{ | ||
| #' write_sessioninfo(file = "sessioninfo.txt") | ||
| #' } | ||
| write_sessioninfo <- function(file) { | ||
|
hansvancalster marked this conversation as resolved.
|
||
|
|
||
| platform_info()[c("version", | ||
| "os", | ||
| "system", | ||
| "ctype")] %>% | ||
| unlist %>% | ||
| as.matrix() %>% | ||
| write.table(file = file, | ||
| quote = FALSE, | ||
| col.names = FALSE, | ||
| sep = "\t") | ||
|
|
||
| capture.output(cat("\n"), | ||
| file = file, | ||
| append = TRUE) | ||
|
|
||
| package_info() %>% | ||
| as.data.frame %>% | ||
| mutate(non_cran = ifelse(str_detect(source, "CRAN"), | ||
| "", | ||
| source)) %>% | ||
| select(.data$package, | ||
| .data$loadedversion, | ||
| .data$date, | ||
| .data$non_cran) %>% | ||
| write.table(file = file, | ||
| quote = FALSE, | ||
| row.names = FALSE, | ||
| col.names = FALSE, | ||
| sep = " ", | ||
| append = TRUE) | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,5 @@ StripTrailingWhitespace: Yes | |
| BuildType: Package | ||
| PackageUseDevtools: Yes | ||
| PackageInstallArgs: --no-multiarch --with-keep.source | ||
| PackageCheckArgs: --as-cran | ||
| PackageRoxygenize: rd,collate,namespace | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hansvancalster I don't know the precise implications of these two lines, but it is package wide and should probably be reviewed in a separate PR?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry 😉 I just misused your PR to add these lines to the .Rproj file. They aid in checking the package when it is built. @ThierryO advised to include these settings in the .Rproj file and he can tell you more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're welcome. |
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.