-
Notifications
You must be signed in to change notification settings - Fork 2
/
.Rprofile
175 lines (143 loc) · 5.17 KB
/
.Rprofile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# ------------------------------------------------------------------------
#
# Title : .Rprofile - Jimmy Briggs
# By : Jimmy Briggs
# Date : 2021-04-13
#
# ------------------------------------------------------------------------
# Ensure Library is set:
#.libPaths("~/.config/R/lib/4.1")
# Set Default Options:
options(
repos = c(CRAN = "https://cran.rstudio.com"),
editor = "notepad",
pager = "internal",
useFancyQuotes = FALSE,
tab.width = 2,
browserNLdisabled = TRUE,
max.print = 200,
shiny.launch.browser = TRUE,
Ncpus = 4L, # parallel package installations (Sys.getenv("NUMBER_OF_PROCESSORS")` or parallel::detectCores())
scipen = 999, # Remove Scientific Notation
languageserver.snippet_support = FALSE, # vscode language server
vsc.use_httpgd = TRUE,
languageserver.server_capabilities = list(documentHighlightProvider = FALSE),
remotes.install.args = "--no-multiarch", # avoid i386 arch installations/compilations:
devtools.install.args = "--no-multiarch",
usethis.full_name = "Jimmy Briggs", # usethis
usethis.protocol = "ssh",
usethis.description = list(
`Authors@R` = 'person("Jimmy", "Briggs",
email = "[email protected]",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-7489-8787"))',
License = "MIT + file LICENSE",
Language = "en-US"
),
orcid = "0000-0002-7489-8787",
blogdown.author = "Jimmy Briggs", # blogdown - https://bookdown.org/yihui/blogdown/global-options.html
blogdown.ext = ".Rmd",
blogdown.insertimage.usebaseurl = TRUE,
shrtcts.path = path.expand("~/.config/R/config/.shrtcts.yml") #,
# gargle_oauth_email = "[email protected]",
# gargle_oauth_cache = path.expand("~/.R/gargle/gargle-oauth")
)
# turn on completion of installed package names
utils::rc.settings(ipck = TRUE)
# addinit options
source(path.expand("~/.config/R/scripts/addinit_options.R"))
# history
Sys.setenv("R_HISTFILE" = path.expand("~/.config/R/.Rhistory"))
.Last <- function() if (interactive()) try(savehistory(path.expand("~/.config/R/.Rhistory")))
# error tracing
if ('rlang' %in% loadedNamespaces()) options(error = rlang::entrace)
# package installation error callback from 'pak'
if (interactive() && getRversion() >= "4.0.0") {
globalCallingHandlers(
packageNotFoundError = function(err) {
try(pak::handle_package_not_found(err))
}
)
}
# prompt
setHook("rstudio.sessionInit", function(newSession) {
if (newSession)
message("RStudio Version: ", rstudioapi::getVersion())
}, action = "append")
if (interactive() && curl::has_internet()) invisible(installr::check.for.updates.R(GUI = FALSE))
# r-cli
if (nzchar(Sys.getenv("R_CMD")) && require("rcli", quietly = TRUE)) rcli::r_cmd_call()
# shortcuts
# if (interactive() && requireNamespace("shrtcts", quietly = TRUE)) {
# shrtcts::add_rstudio_shortcuts(
# path = getOption("shrtcts.path"),
# set_keyboard_shortcuts = TRUE
# )
# }
# load secret environment variables/tokens
local({
if (!file.exists(fs::path_home(".config/R/secrets/secrets.Renviron"))) {
secrets <- config::get("secrets", file = fs::path_home(".config/R/config.yml"))
if (!require(gistr)) {
if (file.exists(secrets$local_path)) {
file.rename(secrets$local_path, paste0(secrets$local_path, ".bak"))
}
suppressMessages(
utils::download.file(secrets$url, secrets$local_path, quiet = TRUE)
)
}
}
})
readRenviron(fs::path_home(".config/R/secrets/secrets.Renviron"))
# attach extra helper functions
.rprofile <- new.env()
sys.source(path.expand("~/.config/R/scripts/rprofile_extras.R"), .rprofile)
attach(.rprofile)
# detach
detach_all_attached()
# clear env
rm(list = ls())
# autoload magrittr PIPE
autoload("%>%", "magrittr")
# unload
# deprecated --------------------------------------------------------------
# if (requireNamespace("jetpack", quietly = TRUE)) {
# jetpack::load()
# } else {
# message("Install Jetpack to use a virtual environment for this project")
# }
# Set GH PAT
# local({
# require("credentials")
# credentials::set_github_pat()
# })
# set locale
# invisible(Sys.setlocale("LC_ALL", "English_United States.1252"))
# parallel::detectCores()
# benchmarkme::get_ram()
# benchmarkme::get_cpu()
# default to launching shiny apps in external browser
# if (requireNamespace("rstudioapi", quietly = TRUE) && rstudioapi::hasFun("viewer")) {
# options(shiny.launch.browser = .rs.invokeShinyWindowExternal)
# }
# shrtcts::list_shortcuts()
# if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install(version = "3.12")
# else {
# gistr::gist_save(secrets$local_path, secrets$ _gist_path)
# }
# prompt::set_prompt(function(...){
# paste0(
# "[", prompt::git_branch(), prompt::git_dirty(), prompt::git_arrows(), "] ",
# prompt::prompt_memuse()
# )
# })
# options(
# kickstarteR.setup = list(
# packages = c('dplyr', 'purrr', 'lubridate', 'stringr', 'rstudioapi', 'pak', 'pacman', 'devtools'),
# sets = list(
# shiny = c('shiny', 'shinydashboard', 'shinyWidgets', 'DT', 'highcharter', 'shinyjs'),
# tidy = c('dplyr', 'reshape2'),
# excel = c('readxl', 'writexl')
# )
# )
# )