Skip to content
Closed
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: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: inborutils
Title: Collection of Useful R Utilities
Version: 0.1.0.9061
Version: 0.1.0.9062
Description: While working on research projects, typical small functionalities
are useful across these projects. Instead of copy-pasting these functions in
all indidivual project repositories/folders, this package collects these
Expand All @@ -15,6 +15,7 @@ Authors@R: c(
person("Thierry", "Onkelinx", role = "ctb", email = "thierry.onkelinx@inbo.be", comment = c(ORCID = "0000-0001-8804-4216")),
person("Floris", "Vanderhaeghe", role = "ctb", email = "floris.vanderhaeghe@inbo.be", comment = c(ORCID = "0000-0002-6378-6229")),
person("Pieter", "Verschelde", role = "ctb", email = "pieter.verschelde@inbo.be", comment = c(ORCID = "0000-0002-9199-421X")),
person("Els", "De Bie", role = "ctb", email = "els.debie@inbo.be", comment = c(ORCID = "0000-0001-7679-743X")),
person("Research Institute for Nature and Forest (INBO)", role = "cph", email = "info@inbo.be")
)
License: MIT + file LICENSE
Expand All @@ -41,6 +42,7 @@ Imports:
rgdal,
rlang,
RSQLite,
sessioninfo,
sp,
sf,
stats,
Expand Down
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export(read_knmi_data)
export(read_mow_data)
export(reproject_coordinates)
export(vif)
export(write_sessioninfo)
exportMethods(dbDisconnect)
importFrom(DBI,dbConnect)
importFrom(DBI,dbDisconnect)
Expand Down Expand Up @@ -104,6 +105,8 @@ importFrom(readr,read_delim_chunked)
importFrom(rgbif,name_backbone)
importFrom(rlang,"!!")
importFrom(rlang,.data)
importFrom(sessioninfo,package_info)
importFrom(sessioninfo,platform_info)
importFrom(sf,st_as_sf)
importFrom(sf,st_coordinates)
importFrom(sf,st_crs)
Expand All @@ -118,10 +121,13 @@ 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)
71 changes: 71 additions & 0 deletions R/write_sessioninfo.R
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
Comment thread
hansvancalster marked this conversation as resolved.
#' \dontrun{
#' write_sessioninfo(file = "sessioninfo.txt")
#' }
write_sessioninfo <- function(file) {
Comment thread
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)

}
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ reference:
contents:
- df_factors_to_char
- csv_to_sqlite
- title: "Enhancing transparency and reproducibility"
desc: "Functions to help in achieving transparency and reproducibility"
contents:
- write_sessioninfo
- title: "Statistical modelling"
desc: "Functions for handling statistical modelling tasks"
contents:
Expand Down
2 changes: 2 additions & 0 deletions inborutils.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace

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.

@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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

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.

You're welcome.

1 change: 1 addition & 0 deletions man/inborutils-package.Rd

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

31 changes: 31 additions & 0 deletions man/write_sessioninfo.Rd

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