generated from UBESP-DCTV/laims.analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rprofile
113 lines (98 loc) · 3.32 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
source("renv/activate.R")
# if (!interactive()) renv::restore(rebuild = "igraph")
options(
tidyverse.quiet = TRUE
)
stopifnot(
`env var "PROJ_TITLE" must be set` = Sys.getenv("PROJ_TITLE") != "",
`env var "PROJ_DESCRIPTION" must be set` =
Sys.getenv("PROJ_DESCRIPTION") != "",
`env var "PROJ_URL" must be set` = Sys.getenv("PROJ_URL") != ""
)
if (interactive()) {
suppressPackageStartupMessages(suppressWarnings({
usethis::ui_todo(
"Interactive session detected. Attaching dev packages."
)
library(usethis)
ui_info("package {ui_value('usethis')} attached.")
library(devtools)
ui_info("package {ui_value('devtools')} attached.")
library(checkmate)
ui_info("package {ui_value('checkmate')} attached.")
library(testthat)
ui_info("package {ui_value('testthat')} attached.")
library(targets)
ui_info("package {ui_value('targets')} attached.")
ui_done("Dev packages attached.")
ui_info(
"Note: This will not be done in any non-interactive session!"
)
}))
if (
interactive() &&
requireNamespace("rstudioapi") &&
fs::file_exists("01-FIRST_RUN.R")
) {
# https://github.com/rstudio/rstudioapi/issues/100
setHook(
"rstudio.sessionInit",
function(newSession) {
if (newSession) {
rstudioapi::navigateToFile("01-FIRST_RUN.R")
}
},
action = "append"
)
}
if (Sys.getenv("PRJ_SHARED_PATH") == "") {
usethis::ui_info(paste0(
"Environmental variable {usethis::ui_field('PRJ_SHARED_PATH')} ",
"is not set."
))
usethis::ui_info(paste0(
"If you like, you can set it to a shared path for the project.\n",
"You can set it in the {usethis::ui_value('.Renviron')} file.\n",
"Open {usethis::ui_value('.Renviron')} by ",
"{usethis::ui_code('usethis::edit_r_environ(\"project\")')}."
))
Sys.setenv(PRJ_SHARED_PATH = normalizePath(here::here()))
usethis::ui_done(paste0(
"Default path is set to the current project folder; ",
"i.e., the {usethis::ui_value('_targets/')} folder is not shared."
))
}
Sys.setenv(
"PRJ_SHARED_PATH" = path.expand(Sys.getenv("PRJ_SHARED_PATH"))
)
if (!(fs::is_dir(Sys.getenv("PRJ_SHARED_PATH")))) {
usethis::ui_stop(paste0(
"Environmental variable {usethis::ui_field('PRJ_SHARED_PATH')} ",
"is currently set to\n",
"{usethis::ui_value(Sys.getenv('PRJ_SHARED_PATH'))}.\n",
"That path is not a valid folder (in your current system).\n",
"You must set/update the filed ",
"{usethis::ui_field('PRJ_SHARED_PATH')} of ",
"{usethis::ui_value('.Renviron')} to a valid folder.\n",
"You can open {usethis::ui_value('.Renviron')} by running ",
"{usethis::ui_code('usethis::edit_r_environ(\"project\")')}."
))
}
.get_prj_shared_path <- function() {
Sys.getenv('PRJ_SHARED_PATH') |>
normalizePath(winslash = "/", mustWork = FALSE)
}
targets::tar_config_set(
store = file.path(.get_prj_shared_path(), "_targets")
)
targets::tar_config_set(
script = here::here("_targets.R"),
store = file.path(.get_prj_shared_path(), "_targets"),
config = "tests/testthat/_targets.yaml"
)
targets::tar_config_set(
script = here::here("_targets.R"),
store = file.path(.get_prj_shared_path(), "_targets"),
config = "reports/_targets.yaml"
)
}