Skip to content

Instantly share code, notes, and snippets.

@CGMossa
Last active February 11, 2020 17:34
Show Gist options
  • Save CGMossa/9534012b1f3c2ce848ac7932a7d3b621 to your computer and use it in GitHub Desktop.
Save CGMossa/9534012b1f3c2ce848ac7932a7d3b621 to your computer and use it in GitHub Desktop.
#TODO: Find a way to restart R without using this particular .Rprofile.
#
# CLEAN_SESSION <- TRUE
CLEAN_SESSION <- FALSE
if (interactive() && !CLEAN_SESSION) {
# Configure session -------------------------------------------------------
message("Interactive mode configuration")
message("Disabled execute next line as default in browser()-calls")
options(browserNLdisabled = TRUE)
# default_error <- options("error")$error
#
# options(error = browser)
#
# message("Set error handling to `recover`.")
# options(error = utils::recover)
# options(error = function(...) {
#
# # options("error")$error(...);
# browser()
# options("old_error")$error()
# utils::recover()
# })
message("Assigning rlang::entrace to be the error-handler")
if (requireNamespace("rlang", quietly = FALSE)) {
options(error = rlang::entrace)
}
# Amend errors
# Revert
# options(error = default_error)
#TODO: add more messages
message("Warnings on partial matches. (Just use auto-complete...)")
options(
warnPartialMatchArgs = TRUE,
warnPartialMatchDollar = TRUE,
warnPartialMatchAttr = TRUE,
# check.bounds = TRUE,
CBoundsCheck = TRUE,
nwarnings = 1e6,
warn.FPU = TRUE #windows only
)
message("Setting show.error.locations to TRUE")
options(show.error.locations = TRUE)
message("Setting keep.source.pkgs to TRUE")
options(keep.source.pkgs = TRUE)
message("Requiring that packages compile from source -- always")
options(install.packages.compile.from.source = 'always')
# this is due to github authentication issues
options(usethis.protocol = "https")
# SOURCE: Matt Denwood
# Because I can never remember which way round these are:
# logit <- stats::qlogis
# inv_logit <- stats::plogis
# # A function to guard against problems with sample():
# resample <- function(x, ...) {
# x[sample.int(n = length(x), ...),]
# }
#
# # ggplot2 colour wheel for getting the standard ggplot colour palette:
# gg_colour_hue <- function(n) {
# hues = seq(15, 375, length = n + 1)
# hcl(h = hues, l = 65, c = 100)[1:n]
# }
# require(conflicted, warn.conflicts = TRUE)
require(fcuk, warn.conflicts = TRUE)
require(magrittr, warn.conflicts = TRUE)
require(devtools, warn.conflicts = TRUE)
require(usethis, warn.conflicts = TRUE)
require(glue, warn.conflicts = TRUE)
message("Loading testthat without old-style objects.")
require(testthat, exclude = c("context", "expect_that",
"is_null", "is_a", "is_true", "is_false", "has_names", "is_less_than",
"is_more_than", "equals", "is_equivalent_to", "is_identical_to",
"equals_reference", "shows_message", "gives_warning", "prints_text",
"throws_error", "matches", "not"))
require(searcher, warn.conflicts = TRUE)
# this is an extreme package. it searches for the error every time.
# require(errorist, warn.conflicts = TRUE)
require(zeallot, warn.conflicts = TRUE)
}
# Remove CLEAN_SESSION ----------------------------------------------------
rm(CLEAN_SESSION)
@CGMossa
Copy link
Author

CGMossa commented Dec 20, 2019

Added {zeallot}, because why not..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment