-
Notifications
You must be signed in to change notification settings - Fork 8
/
Rprofile.site
executable file
·208 lines (167 loc) · 7.29 KB
/
Rprofile.site
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#source("renv/activate.R")
## Emacs please make this -*- R -*-
## empty Rprofile.site for R on Debian
##
## Copyright (C) 2008 - 2018 Dirk Eddelbuettel and GPL'ed
##
## see help(Startup) for documentation on ~/.Rprofile and Rprofile.site
# ## Example of .Rprofile
# options(width=65, digits=5)
# options(show.signif.stars=FALSE)
# setHook(packageEvent('grDevices', 'onLoad'),
# function(...) grDevices::ps.options(horizontal=FALSE))
# set.seed(1234)
# .First <- function() cat("\n Welcome to R!\n\n")
# .Last <- function() cat("\n Goodbye!\n\n")
## ======================== Micro Editor ===================================
## https://www.tecmint.com/micro-linuxtext-editor-with-syntax-highlighting/
## Micro – A Modern Terminal Based Text Editor with Syntax Highlighting
## ============================= PATH ======================================
#system('sudo chmod +rwx /usr/lib/R')
.pth <- .libPaths(c('/usr/lib/R/library')) #, '/usr/lib/R/site-library'))
.libPaths(.pth)
## https://support.rstudio.com/hc/en-us/articles/200532197
## https://community.rstudio.com/t/r-does-not-display-korean-chinese/30889/3?u=englianhu
#Sys.setlocale("LC_CTYPE", "en_US.UTF-8")
#Sys.setlocale("LC_CTYPE", "zh_CN.UTF-8")
#Sys.setlocale(category = "LC_CTYPE", "Chinese (Simplified)_China.936")
#Sys.setlocale(locale = "Chinese")
#Sys.setlocale(locale = "Japanese")
#Sys.setlocale(locale = "English")
# rmarkdown::render('/home/englianhu/Documents/owner/ryo-cn.Rmd', encoding = 'UTF-8')
#Sys.setlocale("LC_CTYPE", "UTF-8")
#Sys.setlocale(locale = "UTF-8")
#Sys.setlocale(category = "LC_ALL", locale = "UTF-8")
#Sys.setlocale(category = "LC_ALL", locale = "Chinese")
#Sys.setlocale(category = "LC_ALL", locale = "zh_CN.UTF-8")
#Sys.setlocale(category = "LC_ALL", locale = "zh_TW.UTF-8")
#Sys.setlocale(category = "LC_ALL", locale = "jp_JP.UTF-8")
options(encoding='UTF-8')
#dir(paste0(R.home(component = 'home'), '/etc'))
## https://www.jumpingrivers.com/blog/customising-your-rprofile/
## -------------------------------------------------------------------------
## https://stackoverflow.com/a/13736073/3806250
# candidates <- c(Sys.getenv('R_PROFILE'),
# file.path(Sys.getenv('R_HOME'), 'etc', 'Rprofile.site'),
# Sys.getenv('R_PROFILE_USER'),
#file.path(getwd(), '.Rprofile') )
#
# Filter(file.exists, candidates)
## https://github.com/rstudio/reticulate/issues/496#issuecomment-601446838
#Sys.setenv(RETICULATE_PYTHON = '/usr/bin/python3')
#Sys.setenv(RETICULATE_PYTHON = '/home/englianhu/anaconda3/bin/python')
## https://d.cosx.org/d/422269-r-410/11
Sys.setenv(RETICULATE_PYTHON = '/home/englianhu/anaconda3/bin/python3',
'_R_USE_PIPEBIND_' = 'true')
#Sys.setenv(RETICULATE_PYTHON = '/home/englianhu/anaconda3/envs/py38/bin/python')
## -------------------------------------------------------------------------
## We set the cloud mirror, which is 'network-close' to everybody, as default
local({
#r <- getOption('repos')
#r['CRAN'] <- 'https://cloud.r-project.org'
#options(repos = r)
## https://radiant-rstats.github.io/docs/install.html
options(repos = c(CRAN = 'https://cloud.r-project.org',
RSM = 'https://radiant-rstats.github.io/minicran',
Omega = 'http://www.omegahat.net/R',
CINC = 'https://cinc.rud.is',
RForge = 'https://www.rforge.net',
RSpatial = 'https://rspatial.r-universe.dev'),
Stan = 'https://mc-stan.org/r-packages')
#install.packages("remotes")
#remotes::install_github("radiant-rstats/radiant.update", upgrade = "never")
#radiant.update::radiant.update()
#install.packages('cmdstanr', repos = c('https://mc-stan.org/r-packages', getOption('repos')))
})
## ======================== Load Packages ==================================
suppressPackageStartupMessages(require('utils'))
if(!suppressPackageStartupMessages(require('BBmisc'))) {
install.packages('BBmisc', dependencies = TRUE,
INSTALL_opts = '--no-lock')
}
suppressPackageStartupMessages(require('BBmisc'))
if(!suppressPackageStartupMessages(require('rmsfuns'))) {
install.packages('rmsfuns', dependencies = TRUE,
INSTALL_opts = '--no-lock')
}
suppressPackageStartupMessages(require('rmsfuns'))
if(!suppressAll(require('devtools'))) {
install.packages('devtools', dependencies = TRUE,
INSTALL_opts = '--no-lock')
devtools::install_github('r-lib/devtools')
}
if(!suppressAll(require('startup'))) {
## https://github.com/HenrikBengtsson/startup
remotes::install_github('HenrikBengtsson/startup', ref = 'develop')
}
if(!suppressAll(require('Rdym'))) {
devtools::install_github('wrathematics/Rdym')
}
## https://www.jumpingrivers.com/blog/customising-your-rprofile/
if(!suppressAll(require('rprofile'))) {
remotes::install_github('csgillespie/rprofile')
}
if(!suppressAll(require('prompt'))) {
# Used for nice prompts
remotes::install_github('gaborcsardi/prompt')
}
if(!suppressAll(require('colorout'))) {
# Used for nice colours in the terminal; not for Windows
remotes::install_github('jalvesaq/colorout')
}
if(!suppressAll(require('tidyverse'))) {
devtools::install_github('tidyverse/tidyverse')
}
if(!suppressAll(require('lubridate'))) {
devtools::install_github('tidyverse/lubridate')
}
if(!suppressAll(require('prettycode'))) {
devtools::install_github('https://github.com/r-lib/prettycode')
}
#library(prettycode, exclude = c('!', 'print'))
pkgs <- c('MASS', 'devtools', 'lubridate', 'tidyverse', 'rprofile', 'prompt',
'colorout', 'Rdym', 'startup', 'conflicted', 'prettycode')
suppressAll(lib(pkgs))
rm(pkgs)
conflicted::conflict_prefer('print', 'base', quiet=TRUE)
## -------------------------------------------------------------------------
## https://stackoverflow.com/a/17486231/3806250
#.First()
.First <- function() {
Rdym::RdymEnable()
BBmisc::suppressAll(startup::install(path = '/home/englianhu'))
BBmisc::suppressAll(startup::startup())
}
## ======================== Start Up =====================================
# A powerline clone, that also shows the system load average and the current working directory.
if (interactive()) prompt::set_prompt(prompt::new_prompt_powerline())
## https://www.jumpingrivers.com/blog/customising-your-rprofile/
if (interactive() && suppressAll(requireNamespace('rprofile'))) {
# Only useful if you use Makefiles
rprofile::create_make_functions()
# Startup options
rprofile::set_startup_options()
# Not RStudio console
if (rprofile::is_terminal()) {
# https://github.com/csgillespie/rprofile/blob/master/R/set-terminal.R
rprofile::set_terminal()
} else {
rprofile::set_rstudio()
}
.env = rprofile::set_functions()
suppressAll(attach(.env))
# Display wifi and no of R sessions
# Linux only
suppressWarnings(rprofile::set_startup_info())
}
## -------------------------------------------------------------------------
# Prints RStudio project on start-up
setHook('rstudio.sessionInit', function(newSession) {
active_rproj = rprofile::get_active_rproj()
if (!is.null(active_rproj)) {
base::message(glue::glue("{crayon::yellow('R-project:')} {active_rproj}"))
}
}, action = 'append')
#BBmisc::suppressAll(.First())
tryCatch(suppressWarnings(startup::startup(all = TRUE)), error=function(ex)
base::message('.Rprofile error: ', base::conditionMessage(ex)))