Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Imports:
sp,
sf,
stats,
stringr,
tibble,
tidyr,
tidyselect
Expand All @@ -56,7 +55,8 @@ Suggests:
testthat,
ggplot2,
htmlwidgets,
drat
drat,
yaml
LazyData: true
Encoding: UTF-8
VignetteBuilder: knitr
Expand Down
6 changes: 1 addition & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ importFrom(readr,read_delim_chunked)
importFrom(rgbif,name_backbone)
importFrom(rlang,"!!")
importFrom(rlang,.data)
importFrom(sessioninfo,package_info)
importFrom(sessioninfo,platform_info)
importFrom(sessioninfo,session_info)
importFrom(sf,st_as_sf)
importFrom(sf,st_coordinates)
importFrom(sf,st_crs)
Expand All @@ -121,13 +120,10 @@ importFrom(stats,cov2cor)
importFrom(stats,lm)
importFrom(stats,model.matrix)
importFrom(stats,vcov)
importFrom(stringr,str_detect)
importFrom(tibble,as_tibble)
importFrom(tidyr,extract)
importFrom(tidyr,separate)
importFrom(tidyselect,ends_with)
importFrom(tidyselect,enquo)
importFrom(tidyselect,vars_pull)
importFrom(utils,capture.output)
importFrom(utils,getFromNamespace)
importFrom(utils,write.table)
67 changes: 19 additions & 48 deletions R/write_sessioninfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,33 @@
#' \itemize{
#' \item{essential platform info: version, os, system, ctype}
#' \item{essential info on loaded packages: package, loadedversion, date,
#' source if different from CRAN.}
#' source.}
#' }
#'
#' @param file A file path or a \code{\link[base]{connection}}.
#' @inheritParams sessioninfo::session_info
#'
#' @importFrom sessioninfo
#' platform_info
#' package_info
#' @importFrom stringr
#' str_detect
#' @importFrom utils
#' write.table
#' capture.output
#' @importFrom rlang
#' .data
#' @importFrom dplyr
#' mutate
#' select
#' @importFrom sessioninfo session_info
#'
#' @export
#'
#' @examples
#' \dontrun{
#' write_sessioninfo(file = "sessioninfo.txt")
#' write_sessioninfo(file = "sessioninfo.yml")
#' }
write_sessioninfo <- function(file) {

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)

write_sessioninfo <- function(file, pkgs = NULL, include_base = FALSE) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you did not implement the extra arguments?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice line 17: #' @inheritParams sessioninfo::session_info

si <- session_info()
si[["platform"]] <- si[["platform"]][c("version", "os", "system", "ctype")]
relevant <- c("loadedversion", "date", "source")
si[["packages"]] <- apply(
si[["packages"]],
1,
function(x) {
as.list(x[relevant])
}
)
if (!requireNamespace("yaml", quietly = TRUE)) {
stop("please install the 'yaml' package first")
}
yaml::write_yaml(si, file)
}
13 changes: 10 additions & 3 deletions man/write_sessioninfo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.